用过ASP.net + WML开发WAP程序的高手请进来帮帮我,(没分了)
问题:WML中的<Input>标签传送中文字符问题?问题描述:1.传送中文字符的页面Byxx_Qury.aspx代码如下:
<?xml version="1.0" encoding="UTF-8"?>
<%@ Page language="c#" Inherits="Classes.cByxx_Qury" Src="Classes/Byxx_Qury.aspx.cs" %>
<!DOCTYPE wml PUBLIC "-//WAPFORUM//DTD WML 1.2//EN" "http://www.wapforum.org/DTD/wml_1.2.xml">
<wml>
<head>
<meta http-equiv="Cache-Control" content="max-age=0" />
</head>
<%=myContent%>
</wml>
2.cs代码处理如下:
using System;
using System.Configuration;
using System.Web.UI;
using System.Data;
using System.Data.OleDb;
using System.Data.SqlClient;
using Classes;
namespace Classes
{
public class cByxx_Qury: Page
{
protected static string myContent;
protected void Page_Load(Object Src, EventArgs E)
{
Response.ContentType = "text/vnd.wap.wml";
myContent="<card title='信息查询'><p>";
myContent=myContent
+ "请输入栏目名称或关键字:<br/><input name='KeyOrSelKey' type='text' size='35' title='输入栏目名称或关键字'/><br/>"
+ "<a href='ReaderContent.aspx?strKeyOrSelKey=$(KeyOrSelKey)'>确定</a>"
+ "<br/><a href='.'>返回上级</a><br/>"
+ "</p></card>";
byte[] bytes=System.Text.Encoding.UTF8.GetBytes(myContent);
MyContent=System.Text.Encoding.UTF8.GetString(bytes);
}
}
}
3.接收<Input>传值的页面ReaderContent.aspx代码如下:
<?xml version="1.0" encoding="UTF-8"?>
<%@ Page language="c#" Inherits="Classes.cReaderContent" Src="Classes/ReaderContent.aspx.cs" %>
<!DOCTYPE wml PUBLIC "-//WAPFORUM//DTD WML 1.2//EN" "http://www.wapforum.org/DTD/wml_1.2.xml">
<wml>
<head>
<meta http-equiv="Cache-Control" content="max-age=0" />
</head>
<%=myContent%>
</wml>
4。 cs处理如下:
using System;
using System.Configuration;
using System.Web.UI;
using System.Data;
using System.Data.OleDb;
using System.Data.SqlClient;
using Classes;
namespace Classes
{
public class cReaderContent: Page
{
protected static string myContent;
protected void Page_Load(Object Src, EventArgs E)
Response.ContentType = "text/vnd.wap.wml";
string strKeyOrSelKey=Request.QueryString["strKeyOrSelKey"];
string strSQL="select ByxxInfor from v_xxInfo where(ByxxKey='"
+ strKeyOrSelKey.Trim()
+ "' or ByxxSelect='" + strKeyOrSelKey.Trim()
+ "') and Status in (1,2) and ByxxCode<>'SYS-01'
order by [Order],LastTime";
DataTable dt=new DataTable();
dt=SqlHelper.ExecuteSQL(strSQL, CommandType.Text, null);
if(dt.Rows.Count>0)
myContent="<card title='阅读内容'><p>"
+ strKeyOrSelKey + "jgfddgdf </p></card>";
else
{
myContent="<card title='阅读内容'><p>"
+ strKeyOrSelKey + "抱歉!没有内容,请试另一条。</p></card>";
}
byte[] bytes=System.Text.Encoding.UTF8.GetBytes(myContent);
myContent=System.Text.Encoding.UTF8.GetString(bytes);
}
}
}
问题发现,当我在<input>中输入数字或英文字符(即非中文字符是)时,接收页面ReaderContent.aspx的地址栏上显示接受的值是正确的,页面显示strKeyOrSelKey的值于是跟我输入的值一样,但一输入中文字符,就出现很怪的字符象是十六进制,根本得不到正确的sql查询语句。页面显示strKeyOrSelKey为“-”一个减号字符,请问如何解决这样的字符编码问题?
--------------------编程问答-------------------- wap下传汉字参数,要把汉字加密后传过去,接受之后解密,这样是最稳妥的,不管你是utf-8还是别的编码,都不会出错。
补充:.NET技术 , ASP.NET