您的位置:首页 > 编程语言 > ASP

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

2018-10-12 13:52 691 查看
 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"]);

您可能感兴趣的文章:

内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: