胡神

导航

在url中传递中文的解决方案



第一步:

设置web.config

<system>

<globalization requestEncoding="gb2312" responseEncoding="gb2312" culture="zh-CN" fileEncoding="gb2312"/>

</system>

设置aspx

<head runat="server">
    <title>无标题页</title>

  <meta http-equiv="Content-Type" content="text/html;charset=gb2312">
</head>

第二部:

传值方式一:

            string Name = "中国人";
            Response.Redirect("B.aspx?name=" + Server.UrlEncode(Name));

传值方式一:

<head runat="server">
    <title>方式3</title>

    <script language="JavaScript">
    function GoUrl()
    {
        var name = "中国人";
        location.href = "B.aspx?name="+escape(name);
    }
    </script>
</head>
<body onload="GoUrl()">
    <form id="form1" runat="server">
    <div>
    </div>
    </form>
</body>

接收传过来的值:

    if (Request["name"] != null)
    {
        //接收两种方式传过来的值
        string Name = Request["name"];
        Response.Write(Server.UrlDecode(Name));
    } 

posted on 2011-04-12 19:11  胡神  阅读(170)  评论(0)    收藏  举报