HTML里传递变量值(中文)给ASP.NET出现乱码?求救
传递代码
<a href="Sell_List.aspx?Order=<%# DataBinder.Eval(Container.DataItem,"Numbers")%>&Callname=<%# HttpUtility.UrlEncode((DataBinder.Eval(Container.DataItem,"F_CallName")).ToString(),Encoding.UTF8)%>&Tel=<%# DataBinder.Eval(Container.DataItem,"F_Tel")%>&FAX=<%# DataBinder.Eval(Container.DataItem,"F_Fax")%>&Zipcode=<%# DataBinder.Eval(Container.DataItem,"F_Zipcode")%>&Add=<%# HttpUtility.UrlEncode((DataBinder.Eval(Container.DataItem,"F_Add")).ToString(),Encoding.UTF8)%>&Wares=<%# HttpUtility.UrlEncode((DataBinder.Eval(Container.DataItem,"WarehouseNum")).ToString(),Encoding.UTF8)%>&Handle=<%# HttpUtility.UrlEncode((DataBinder.Eval(Container.DataItem,"Handle")).ToString(),Encoding.UTF8)%>&Totals=<%# DataBinder.Eval(Container.DataItem,"Total")%>&Times=<%# HttpUtility.UrlEncode((DataBinder.Eval(Container.DataItem,"Times")).ToString(),Encoding.UTF8)%>" class="A1"><%# DataBinder.Eval(Container.DataItem,"Numbers")%></a>
获取值的代码(语言是ASP.NET):
string NuM=Request.QueryString["Order"].ToString().Trim();
NM.Text=NuM;
TM.Text=Request.QueryString["Times"];
TT.Text=Request.QueryString["Totals"]+" (RMB)";
HT.Text=Request.QueryString["Handle"];
WH.Text=Request.QueryString["Wares"];
NAME.Text = Request.QueryString["Callname"];
TEL.Text = Request.QueryString["Tel"];
FAX.Text = Request.QueryString["Fax"];
ZIP.Text = Request.QueryString["Zip"];
ADD.Text = Request.QueryString["Add"];
asp.net
html
------解决方案--------------------
乱码的话,在接收参数的时候,使用
string args = Server.UrlDecode(Request.QueryString["Order"].ToString().Trim());
------解决方案--------------------使用Server.UrlEncode、Server.UrlDecode进行编码解码
------解决方案--------------------++
------解决方案--------------------举个例子:
第一种:
跳转:Default2.aspx?id=哦,卡姆昂
接受页面:string idddd = Server.UrlDecode(Request["id"].ToString());
结果:idddd为: 哦,卡姆昂
第二种:
跳转:"Default2.aspx?id="+Server.UrlEncode("哦,卡姆昂")
接收页面:string strid = Request["id"].ToString();
结果:strid 为:哦,卡姆昂