473,385 Members | 1,338 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

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 3178
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
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
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
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
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
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
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
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
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...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.