473,498 Members | 1,544 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
<globalization
requestEncoding="UTF-8"
responseEncoding="UTF-8"
fileEncoding="gb2312" />

Jul 19 '05 #1
3 3190
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="WebForm1.aspx.vb"
Inherits="Dummy_ChineseTextAddToPageFromCB.WebForm 1"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0
Transitional//EN">
<HTML>
<HEAD>
<title>WebForm1</title>
<meta name="GENERATOR" content="Microsoft
Visual Studio.NET 7.0">
<meta name="CODE_LANGUAGE" content="Visual
Basic 7.0">
<meta name="vs_defaultClientScript"
content="JavaScript">
<meta name="vs_targetSchema"
content="http://schemas.microsoft.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.EventArgs) Handles MyBase.Load
'Put user code to initialize the page here
Response.Write("<br><br><br><br><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
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
<globalization
requestEncoding="UTF-8"
responseEncoding="UTF-8"
fileEncoding="gb2312" />

.

Jul 19 '05 #2
ok, this is my code behind
using System;
using System.Collections;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using Asialife.Life.Data;
using Asialife.Shared;
using Asialife.Shared.Data;
using Asialife.Shared.Entity;
using Asialife.Common.Charts;

namespace Asialife.NetTools
{
public class LILPFUND_CN : System.Web.UI.Page
{
protected Label UserLabel, MessageLabel, TitleLabel;
protected HtmlForm GridForm;
protected DataGrid ILPListing, ILPFundListing;
protected System.Web.UI.WebControls.Image ChartImage;
protected DropDownList PeriodList;
private ILPData ilpData;

private void Page_Load(object sender, System.EventArgs e)
{
initField();
if ((string)Session["dataViewID"]!="LILPFUND")
{
Session["dataViewID"] = "LILPFUND";
GetData();
}
else
{
bindGrid(1);
bindGrid(2);
}
}

private void GetData()
{
ilpData = new ILPData(PeriodList.SelectedItem.Value);
ilpData.Connect();
ilpData.Retrieve();
ilpData.Disconnect();
if (ilpData.IsExist)
{
Session["dataView"] = new DataView(ilpData.ReportTable);
Session["dataView1"] = new DataView(ilpData.ReportTable);
((DataView)Session["dataView"]).RowFilter="Date > '" +
DateTime.Today.AddDays(-8) + "' AND Date < '" + DateTime.Today + "'";
((DataView)Session["dataView"]).RowStateFilter=
DataViewRowState.CurrentRows;
((DataView)Session["dataView1"]).RowFilter="Fund = '" +
((DataView)Session["dataView1"])[0]["Fund"] + "'";
((DataView)Session["dataView1"]).Sort="Date";
((DataView)Session["dataView1"]).RowStateFilter=
DataViewRowState.CurrentRows;
TitleLabel.Text =
((DataView)Session["dataView1"])[0]["Fund"].ToString();
MessageLabel.Text="";
}
else
{
MessageLabel.Text="No Records Found !";
}
bindGrid(1);
bindGrid(2);
}

public void ILPGridPageChanged(object sender,
DataGridPageChangedEventArgs e)
{
ILPListing.CurrentPageIndex = e.NewPageIndex;
bindGrid(1);
}

public void ILPFundGridPageChanged(object sender,
DataGridPageChangedEventArgs e)
{
ILPFundListing.CurrentPageIndex = e.NewPageIndex;
bindGrid(2);
}

public void fundSelected(object sender, DataGridCommandEventArgs e)
{
TitleLabel.Text = e.Item.Cells[1].Text;
((DataView)Session["dataView1"]).RowFilter="Fund = '" +
e.Item.Cells[1].Text + "'";
((DataView)Session["dataView1"]).RowStateFilter=
DataViewRowState.CurrentRows;
bindGrid(2);
}

public void PeriodChanged(object sender, System.EventArgs e)
{
initGrid(1);
initGrid(2);
GetData();
}

private void initGrid(int gridNo)
{
switch(gridNo)
{
case 1:
ILPListing.CurrentPageIndex=0;
ILPListing.DataSource = new DataView();
ILPListing.DataBind();
break;
case 2:
ILPFundListing.CurrentPageIndex=0;
ILPFundListing.DataSource = new DataView();
ILPFundListing.DataBind();
break;
}
}

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

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

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

/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.Load += new System.EventHandler(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="WebForm1.aspx.vb"
Inherits="Dummy_ChineseTextAddToPageFromCB.WebFor m1"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0
Transitional//EN">
<HTML>
<HEAD>
<title>WebForm1</title>
<meta name="GENERATOR" content="Microsoft
Visual Studio.NET 7.0">
<meta name="CODE_LANGUAGE" content="Visual
Basic 7.0">
<meta name="vs_defaultClientScript"
content="JavaScript">
<meta name="vs_targetSchema"
content="http://schemas.microsoft.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.EventArgs) Handles MyBase.Load
'Put user code to initialize the page here
Response.Write("<br><br><br><br><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
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
<globalization
requestEncoding="UTF-8"
responseEncoding="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
2259
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...
2
1326
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...
0
1441
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...
0
1182
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...
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...
0
2708
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...
0
1257
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...
0
1235
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...
0
7005
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7210
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...
1
6891
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7381
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...
0
4595
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...
0
3096
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...
0
3087
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
659
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
293
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.