473,563 Members | 2,831 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

displaying chinese from code behind

Hi!
I managed to display chinese character in my web form
(.aspx), in certain situation i need to to set the text of
the label of my web form in chinese character
programatically which is done in my code behind.

when running the web form, the character which is entered
directly to the web form during design time is displayed
correctly, while those set from code behind appear as
funny character

can anyone help?

i've changed my web config to the following
<globalizatio n
requestEncoding ="UTF-8"
responseEncodin g="UTF-8"
fileEncoding="g b2312" />

Jul 19 '05 #1
3 3211
SR
Hi

I work with Shift_JIS and have never faced this problem
(though this used to happen in JSP for me and was really a
problem!!!)

I also tried simulating the problem, but watever i do,
aspx page gets rendered properly ;) tried saving the data
in different encodings in the VS.Net IDE. but doesnt give
any probs. Can u post/mail a sample code?
My Code is as follows
<%@ Page Language="vb" AutoEventWireup ="false"
Codebehind="Web Form1.aspx.vb"
Inherits="Dummy _ChineseTextAdd ToPageFromCB.We bForm1"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0
Transitional//EN">
<HTML>
<HEAD>
<title>WebForm1 </title>
<meta name="GENERATOR " content="Micros oft
Visual Studio.NET 7.0">
<meta name="CODE_LANG UAGE" content="Visual
Basic 7.0">
<meta name="vs_defaul tClientScript"
content="JavaSc ript">
<meta name="vs_target Schema"
content="http://schemas.microso ft.com/intellisense/ie5">
</HEAD>
<body MS_POSITIONING= "GridLayout ">
<form id="Form1" method="post"
runat="server">
東京
<br>
とうきょう
<br>
トウキョウ
<br>
<asp:Label id="Label1" style="Z-
INDEX: 101; LEFT: 283px; POSITION: absolute; TOP: 80px"
runat="server"> Label</asp:Label>
<br>
<br>
<br>
<br>
</form>
</body>
</HTML>
Private Sub Page_Load(ByVal sender As System.Object,
ByVal e As System.EventArg s) Handles MyBase.Load
'Put user code to initialize the page here
Response.Write( "<br><br><br><b r><br><br>文章田尻" )
Label1.Text = "文章田尻"

End Sub
regards

sr
-----Original Message-----
Hi!
I managed to display chinese character in my web form
(.aspx), in certain situation i need to to set the text of the label of my web form in chinese character
programaticall y which is done in my code behind.

when running the web form, the character which is entered
directly to the web form during design time is displayed
correctly, while those set from code behind appear as
funny character

can anyone help?

i've changed my web config to the following
<globalizati on
requestEncodin g="UTF-8"
responseEncodi ng="UTF-8"
fileEncoding=" gb2312" />

.

Jul 19 '05 #2
ok, this is my code behind
using System;
using System.Collecti ons;
using System.Componen tModel;
using System.Drawing;
using System.Data;
using System.Web;
using System.Web.Sess ionState;
using System.Web.UI;
using System.Web.UI.W ebControls;
using System.Web.UI.H tmlControls;
using Asialife.Life.D ata;
using Asialife.Shared ;
using Asialife.Shared .Data;
using Asialife.Shared .Entity;
using Asialife.Common .Charts;

namespace Asialife.NetToo ls
{
public class LILPFUND_CN : System.Web.UI.P age
{
protected Label UserLabel, MessageLabel, TitleLabel;
protected HtmlForm GridForm;
protected DataGrid ILPListing, ILPFundListing;
protected System.Web.UI.W ebControls.Imag e ChartImage;
protected DropDownList PeriodList;
private ILPData ilpData;

private void Page_Load(objec t sender, System.EventArg s e)
{
initField();
if ((string)Sessio n["dataViewID "]!="LILPFUND")
{
Session["dataViewID "] = "LILPFUND";
GetData();
}
else
{
bindGrid(1);
bindGrid(2);
}
}

private void GetData()
{
ilpData = new ILPData(PeriodL ist.SelectedIte m.Value);
ilpData.Connect ();
ilpData.Retriev e();
ilpData.Disconn ect();
if (ilpData.IsExis t)
{
Session["dataView"] = new DataView(ilpDat a.ReportTable);
Session["dataView1"] = new DataView(ilpDat a.ReportTable);
((DataView)Sess ion["dataView"]).RowFilter="Da te > '" +
DateTime.Today. AddDays(-8) + "' AND Date < '" + DateTime.Today + "'";
((DataView)Sess ion["dataView"]).RowStateFilte r=
DataViewRowStat e.CurrentRows;
((DataView)Sess ion["dataView1"]).RowFilter="Fu nd = '" +
((DataView)Sess ion["dataView1"])[0]["Fund"] + "'";
((DataView)Sess ion["dataView1"]).Sort="Date";
((DataView)Sess ion["dataView1"]).RowStateFilte r=
DataViewRowStat e.CurrentRows;
TitleLabel.Text =
((DataView)Sess ion["dataView1"])[0]["Fund"].ToString();
MessageLabel.Te xt="";
}
else
{
MessageLabel.Te xt="No Records Found !";
}
bindGrid(1);
bindGrid(2);
}

public void ILPGridPageChan ged(object sender,
DataGridPageCha ngedEventArgs e)
{
ILPListing.Curr entPageIndex = e.NewPageIndex;
bindGrid(1);
}

public void ILPFundGridPage Changed(object sender,
DataGridPageCha ngedEventArgs e)
{
ILPFundListing. CurrentPageInde x = e.NewPageIndex;
bindGrid(2);
}

public void fundSelected(ob ject sender, DataGridCommand EventArgs e)
{
TitleLabel.Text = e.Item.Cells[1].Text;
((DataView)Sess ion["dataView1"]).RowFilter="Fu nd = '" +
e.Item.Cells[1].Text + "'";
((DataView)Sess ion["dataView1"]).RowStateFilte r=
DataViewRowStat e.CurrentRows;
bindGrid(2);
}

public void PeriodChanged(o bject sender, System.EventArg s e)
{
initGrid(1);
initGrid(2);
GetData();
}

private void initGrid(int gridNo)
{
switch(gridNo)
{
case 1:
ILPListing.Curr entPageIndex=0;
ILPListing.Data Source = new DataView();
ILPListing.Data Bind();
break;
case 2:
ILPFundListing. CurrentPageInde x=0;
ILPFundListing. DataSource = new DataView();
ILPFundListing. DataBind();
break;
}
}

private void bindGrid(int gridNo)
{
switch(gridNo)
{
case 1:
ILPListing.Data Source = (DataView)Sessi on["dataView"];
ILPListing.Data Bind();
break;
case 2:
ILPFundListing. DataSource = (DataView)Sessi on["dataView1"];
ILPFundListing. DataBind();
break;
}
}

private void initField()
{
if (!IsPostBack)
{
PeriodList.Item s.Add(new ListItem("Áù¸öÔ Â",
DateTime.Today. AddMonths(-6).ToString("yy yyMMdd")) );
PeriodList.Item s.Add(new ListItem("Ò»Äê" ,
DateTime.Today. AddYears(-1).ToString("yy yyMMdd")) );
PeriodList.Item s.Add(new ListItem("Á½Äê" ,
DateTime.Today. AddYears(-2).ToString("yy yyMMdd")) );
PeriodList.Item s.Add(new ListItem("ÎåÄê" ,
DateTime.Today. AddYears(-5).ToString("yy yyMMdd")) );
}
initGrid(1);
initGrid(2);
}

#region Web Form Designer generated code
override protected void OnInit(EventArg s e)
{
//
// CODEGEN: This call is required by the ASP.NET Web Form Designer.
//
InitializeCompo nent();
base.OnInit(e);
}

/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeCompo nent()
{
this.Load += new System.EventHan dler(this.Page_ Load);

}
#endregion
}
}
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Jul 19 '05 #3
I do not if i have to do some setting on my project or
vs.net
i tried to save the .cs file Chinese Simplified (GB2312) -
Codepage 936, but when i reopen the file without encoding
the funny character will appear again, so each time i want
to recompile my project i have to make sure all web form
that contain chinese character in the code behind is
opened with the encoding or else the chinese character
will appear as funny character
can anyone help me please?
-----Original Message-----
Hi

I work with Shift_JIS and have never faced this problem
(though this used to happen in JSP for me and was really a problem!!!)

I also tried simulating the problem, but watever i do,
aspx page gets rendered properly ;) tried saving the data
in different encodings in the VS.Net IDE. but doesnt give any probs. Can u post/mail a sample code?
My Code is as follows
<%@ Page Language="vb" AutoEventWireup ="false"
Codebehind="We bForm1.aspx.vb"
Inherits="Dumm y_ChineseTextAd dToPageFromCB.W ebForm1"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0
Transitional//EN">
<HTML>
<HEAD>
<title>WebForm1 </title>
<meta name="GENERATOR " content="Micros oft
Visual Studio.NET 7.0">
<meta name="CODE_LANG UAGE" content="Visual
Basic 7.0">
<meta name="vs_defaul tClientScript"
content="JavaS cript">
<meta name="vs_target Schema"
content="htt p://schemas.microso ft.com/intellisense/ie5">
</HEAD>
<body MS_POSITIONING= "GridLayout ">
<form id="Form1" method="post"
runat="server" >
東京
<br>
とうきょう
<br>
トウキョウ
<br>
<asp:Label id="Label1" style="Z-
INDEX: 101; LEFT: 283px; POSITION: absolute; TOP: 80px"
runat="server" >Label</asp:Label>
<br>
<br>
<br>
<br>
</form>
</body>
</HTML>
Private Sub Page_Load(ByVal sender As System.Object,
ByVal e As System.EventArg s) Handles MyBase.Load
'Put user code to initialize the page here
Response.Write( "<br><br><br><b r><br><br>文章田尻" )
Label1.Text = "文章田尻"

End Sub
regards

sr
-----Original Message-----
Hi!
I managed to display chinese character in my web form
(.aspx), in certain situation i need to to set the text

of
the label of my web form in chinese character
programatical ly which is done in my code behind.

when running the web form, the character which is entered directly to the web form during design time is displayed
correctly, while those set from code behind appear as
funny character

can anyone help?

i've changed my web config to the following
<globalizatio n
requestEncodi ng="UTF-8"
responseEncod ing="UTF-8"
fileEncoding= "gb2312" />

.

.

Jul 19 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
2265
by: Antonio Ooi | last post by:
Hi, Probably due to my 'Language for non-Unicode Setting' in Regional Settings, my ASP page keeps outputing the date format as Chinese Simplified characters when issuing say, <%=Now()%>. In addition, my client script also interpret it as Chinese characters, which I don't want it to behave this way. However, I can't remove my 'Chinese (PRC)'...
2
1331
by: dickyho | last post by:
I am now makeing use of Code Warrior to build an application. I ve finished developing the whole interface. But now I need to transform the application to a Chinese version (using Big5). How can I achieve this? It seems that CodeWarrior doesn't support Big5. Should I import any library? Thx for answering my question!
0
1445
by: Coco | last post by:
Hi! I have been searching for solution for the problem i am facing in displaying chinese character in my aspx page initially when i created the aspx page with some chinese chaarcter, it worked perfectly, but i am having problem when setting the label of my page to some chinese character during run-time which i do it from the code behind ...
0
1191
by: Lucas Tam | last post by:
Hi all, Is there anything special I need to do to output Chinese text into Combo boxes? I can display chinese text in labels, but when I databind to a combobox, all the chinese characters are outputted as question marks. For example, the HTML looks like:
3
369
by: Coco | last post by:
Hi! I managed to display chinese character in my web form (.aspx), in certain situation i need to to set the text of the label of my web form in chinese character programatically which is done in my code behind. when running the web form, the character which is entered directly to the web form during design time is displayed correctly,...
0
2710
by: slchslch | last post by:
Hi all, I have search through multiple forum to look for the respective solution for this problem but still i do not find any solution to this problem. I have Samsung SGH-D520 on hand which is able to display the Chinese & Thai font on the phone menu's by using the pre-set system language. Using the same code in java J2ME game to display...
0
1264
by: Andy Lim | last post by:
Hi all, In my recent project, my client uses Chinese Star software to type the articles in chinese (using MS Word), and I need to display these articles within ASP.NET pages. And, for this very purpose I also installed a copy of Chinese Star software in my development machine, so I can correctly renders the doc correctly. Ussually I just...
0
1249
by: Andy Lim | last post by:
Hi all, In my recent project, my client uses Chinese Star software to type the articles in chinese (using MS Word), and I need to display these articles within ASP.NET pages. And, for this very purpose I also installed a copy of Chinese Star software in my development machine, so I can correctly renders the doc correctly. Ussually I just...
0
7664
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7885
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
8106
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
0
7948
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6250
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5484
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
5213
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3642
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
1
1198
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.