无法使用aspx显示日文文本 [英] Trouble displaying Japanese text with aspx

查看:102
本文介绍了无法使用aspx显示日文文本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

朋友,


我在使用.net 2.0框架的aspx页面中在文本框中显示日文文本(或其他任何地方的
)时遇到问题。初始

日语默认文本显示完美,但当我尝试在按钮点击事件后更改文本
时,它显示为垃圾。

我已经尝试在web.config文件中设置全球化标签,但

无法帮助。

< globalization requestEncoding =" UTF- 8英寸responseEncoding =" UTF-8"

fileEncoding =" UTF-8" />


我应该提一下我的问题不会发生开发pc

我在哪里使用Visual Web Developer 2005 IDE。当我将文件部署到Windows 2000上的实际IIS网络服务器时,它只发生了



非常感谢任何帮助。

这就是我所拥有的:


1. TestJP.aspx包含:

<%@ Page Language =" C#" ; AutoEventWireup =" true"
CodeFile =" TestJP.aspx.cs"继承= QUOT; TestJP" %>


<!DOCTYPE html PUBLIC" - // W3C // DTD XHTML 1.0 Transitional // EN" http://

www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">


< html xmlns = QUOT; HTTP://www.w3.org/1999/xhtml" >

< head runat =" server">

< meta http-equiv =" Content-Type"含量=" text / html的; charset = utf-8">

< title>测试JP< / title>

< / head>

< body> ;

< form id =" form1" runat =" server">

< div>

< asp:TextBox ID =" txtJP" RUNAT = QUOT;服务器"高度=101px

宽度=" 374px">默认日文文本< / asp:TextBox>

< br />

< asp:Button ID =" cmdJP" RUNAT = QUOT;服务器" Text =" Change Text"

OnClick =" cmdJP_Click" />

< / div>

< / form>

< / body>

< / html>


2. TestJP.aspx.cs包含:

使用System;

使用System.Data;

使用System.Configuration;

使用System.Collections;

使用System.Web;

使用System。 Web.Security;

使用System.Web.UI;

使用System.Web.UI.WebControls;

使用System.Web.UI .WebControls.WebParts;

使用System.Web.UI.HtmlControls;


公共部分类TestJP:System.Web.UI.Page

{

protected void Page_Load(object sender,EventArgs e)

{


}

protected void cmdJP_Click(object sender,EventArgs e)

{

txtJP.Text =" New Japanese text";

}

}

解决方案

5月8日上午9:16,pardesiya< zenst ... @ gmail.comwrote:


朋友,


我在aspx中的文本框中显示日文文本时遇到问题(或者在其他任何地方显示

) .net 2.0框架的页面。初始

日语默认文本显示完美,但当我尝试在按钮点击事件后更改文本
时,它显示为垃圾。

我已经尝试在web.config文件中设置全球化标签,但

无法帮助。

< globalization requestEncoding =" UTF- 8英寸responseEncoding =" UTF-8"

fileEncoding =" UTF-8" />


我应该提一下我的问题不会发生开发pc

我在哪里使用Visual Web Developer 2005 IDE。当我将文件部署到Windows 2000上的实际IIS网络服务器时,它只发生了



非常感谢任何帮助。

这就是我所拥有的:


1. TestJP.aspx包含:

<%@ Page Language =" C#" ; AutoEventWireup =" true"
CodeFile =" TestJP.aspx.cs"继承= QUOT; TestJP" %>


<!DOCTYPE html PUBLIC" - // W3C // DTD XHTML 1.0 Transitional // EN" http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">


< html xmlns =" http:// www .w3.org / 1999 / XHTML" >

< head runat =" server">

< meta http-equiv =" Content-Type"含量=" text / html的; charset = utf-8">

< title>测试JP< / title>

< / head>

< body> ;

< form id =" form1" runat =" server">

< div>

< asp:TextBox ID =" txtJP" RUNAT = QUOT;服务器"高度=101px

宽度=" 374px">默认日文文本< / asp:TextBox>

< br />

< asp:Button ID =" cmdJP" RUNAT = QUOT;服务器" Text =" Change Text"

OnClick =" cmdJP_Click" />

< / div>

< / form>

< / body>

< / html>


2. TestJP.aspx.cs包含:

使用System;

使用System.Data;

使用System.Configuration;

使用System.Collections;

使用System.Web;

使用System。 Web.Security;

使用System.Web.UI;

使用System.Web.UI.WebControls;

使用System.Web.UI .WebControls.WebParts;

使用System.Web.UI.HtmlControls;


公共部分类TestJP:System.Web.UI.Page

{

protected void Page_Load(object sender,EventArgs e)

{


}

protected void cmdJP_Click(object sender,EventArgs e)

{

txtJP.Text =" New Japanese text";

}


} - 隐藏引用的文字 -


- 显示引用的文字 -



转到Fi le - 保存.aspx As - 指向保存并选择保存

编码...您使用什么编码来保存文件?


5月8日上午9:30,Alexey Smirnov< alexey.smir ... @ gmail.comwrote:


转到文件 - 保存.aspx As - 指向保存并选择保存

编码...您使用什么编码来保存文件? - 隐藏引用文本 -



等等......你必须检查TestJP.aspx.cs文件的编码。

它似乎以不同的编码保存...


Alexey非常感谢您提出的建议。这很有效!

TestJP.aspx.cs和TestJP.aspx与Shift_JIS一起保存。改为

到UTF-8并且工作正常!


我有第二个问题是相关的。我将数据查询到数据集

并在同一文本框中显示结果,但它显示为垃圾。

有什么办法可以设置DataSet的字符集吗?该数据库可能是用Unicode编码的



DataSet dsTables = new DataSet();

dsTables =< code to从数据库获取数据>

txtJP.Text = dsTables.Tables [0] .Rows [0] [" japanese_name"]。ToString();


Friends,

I am having trouble displaying Japanese text within a textbox (or
anywhere else) in an aspx page with .net 2.0 framework. Initial
default text in Japanese displays perfectly but when I attempt to
change the text following a button-click event, it displays as junk.

I have tried setting the globalization tag in the web.config file but
that does not help eiter.
<globalization requestEncoding="UTF-8" responseEncoding="UTF-8"
fileEncoding="UTF-8"/>

I should mention that the problem does not happen in my development pc
where I am using the Visual Web Developer 2005 IDE. It happens only
when I deploy the files to the actual IIS webserver on Windows 2000.

Would greatly appreciate any help.

Here''s what I have:

1. TestJP.aspx contains:
<%@ Page Language="C#" AutoEventWireup="true"
CodeFile="TestJP.aspx.cs" Inherits="TestJP" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://
www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Test JP</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:TextBox ID="txtJP" runat="server" Height="101px"
Width="374px">Default Japanese Text</asp:TextBox>
<br />
<asp:Button ID="cmdJP" runat="server" Text="Change Text"
OnClick="cmdJP_Click" />
</div>
</form>
</body>
</html>

2. TestJP.aspx.cs contains:
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

public partial class TestJP : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{

}
protected void cmdJP_Click(object sender, EventArgs e)
{
txtJP.Text = "New Japanese text";
}
}

解决方案

On May 8, 9:16 am, pardesiya <zenst...@gmail.comwrote:

Friends,

I am having trouble displaying Japanese text within a textbox (or
anywhere else) in an aspx page with .net 2.0 framework. Initial
default text in Japanese displays perfectly but when I attempt to
change the text following a button-click event, it displays as junk.

I have tried setting the globalization tag in the web.config file but
that does not help eiter.
<globalization requestEncoding="UTF-8" responseEncoding="UTF-8"
fileEncoding="UTF-8"/>

I should mention that the problem does not happen in my development pc
where I am using the Visual Web Developer 2005 IDE. It happens only
when I deploy the files to the actual IIS webserver on Windows 2000.

Would greatly appreciate any help.

Here''s what I have:

1. TestJP.aspx contains:
<%@ Page Language="C#" AutoEventWireup="true"
CodeFile="TestJP.aspx.cs" Inherits="TestJP" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Test JP</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:TextBox ID="txtJP" runat="server" Height="101px"
Width="374px">Default Japanese Text</asp:TextBox>
<br />
<asp:Button ID="cmdJP" runat="server" Text="Change Text"
OnClick="cmdJP_Click" />
</div>
</form>
</body>
</html>

2. TestJP.aspx.cs contains:
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

public partial class TestJP : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{

}
protected void cmdJP_Click(object sender, EventArgs e)
{
txtJP.Text = "New Japanese text";
}

}- Hide quoted text -

- Show quoted text -

Go to File - Save .aspx As - point to Save and select Save with
Encoding... What encoding do you use to save the file?


On May 8, 9:30 am, Alexey Smirnov <alexey.smir...@gmail.comwrote:

Go to File - Save .aspx As - point to Save and select Save with
Encoding... What encoding do you use to save the file?- Hide quoted text -

Wait... you have to check the encoding for your TestJP.aspx.cs file.
It seems that it saved in a different encoding...


Alexey thanks a lot for your prompt suggestion. That worked!
TestJP.aspx.cs and TestJP.aspx were saved with Shift_JIS. Changed
that to UTF-8 and it works fine!

I have a second question which is related. I query data into a dataset
and display the result in the same text box but it appears junk. Is
there any way I should set the charset of the DataSet? The database is
probably encoded with Unicode.

DataSet dsTables = new DataSet();
dsTables = <code to get data from database>
txtJP.Text = dsTables.Tables[0].Rows[0]["japanese_name"].ToString();


这篇关于无法使用aspx显示日文文本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆