asp.net中在用ajax格式传递数据到aspx页面时出现乱码

 更新时间:2013年01月11日 15:04:33   作者:  
asp.net中在用ajax格式传递数据到aspx页面时有时会出现乱码,很是疑惑,不要走开接下来介绍解决方法,感兴趣的朋友可以了解下
 asp.net中在用ajax格式传递数据到aspx页面时有时会出现乱码,以下为解决方法

js中
复制代码 代码如下:

XmlHttp.open("POST", "test.aspx", false);
XmlHttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
XmlHttp.send("QueryName=" + escape(Queryname) + "&QuerySex=" +escape(Querysex));

在test.aspx中
复制代码 代码如下:

string QueryName = HttpUtility.UrlDecode(Request.Params["QueryName"]);
string QuerySex = HttpUtility.UrlDecode(Request.Params["QuerySex"]);

相关文章

最新评论