博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理

asp.net,js传递汉字参数乱码

Posted on 2007-03-27 19:35  小飞龙(Jack)  阅读(860)  评论(0编辑  收藏  举报

使用Response.Redirect方法传递汉字,有时会发现所传递的值和接收到的内容不符,接收的值丢失几个字或变成一堆乱码.

Response.Redirect(
                                    "~/Public/RoleManagement/EditRole.aspx?RoleID=" + RoleID.ToString()
                                    + "&RoleName=" + Server.UrlEncode(RoleName) + "&RoleDescription=" + Server.UrlEncode(RoleDescription)                           
                               );




使用Response.Redirect方法传递 汉字
页面A传递值的代码:
String Message=Server.UrlEncode("欢迎学习ASP.NET");
Response.Redirect("WebForm2.aspx?Msg="+Message);

页面B接收值的代码:
string Message=Server.UrlDecode("Request.QueryString["Msg"]);

Javascript

strFeatures="dialogWidth=600px;dialogHeight=470px;center=yes;middle=yes ;help=no;status=no;scroll=no";
url=encodeURI("../oBILL/RecipeSel.aspx?Name="+ '张' + "&Hj=" + '22');
showModalDialog(url,window,strFeatures);