Passing Chinese parameters in the asp.net page

Source: Internet
Author: User
Tags config urlencode
Asp.net| Page | Chinese 1. Set up Web.config file.
<system.web>
......
<globalization requestencoding= "gb2312" responseencoding= "gb2312" culture= "ZH-CN" fileencoding= "gb2312"/>
......
</system.web>

Or:
aspx file:
<meta http-equiv= "Content-type" content= "text/html; charset=gb2312 ">

2. Before passing the Chinese language, the Chinese parameters to be passed are encoded and decoded at the time of receiving.
>> to deliver
String Name = "Chinese parameters";
Response.Redirect ("B.aspx?") Name= "+server.urlencode (Name));

>> to receive
String Name = request.querystring["name"];
Response.Write (Server.urldecode (Name));
Or:

Navigateurl= ' <%# ' webform2.aspx? Singer= "+ httputility.urlencode (" Chinese ", System.Text.Encoding.GetEncoding (" GB2312 "))%> '


3. If it's from. HTML file to. Aspx file to pass the Chinese parameter (that is, do not use the Redirect () method for URL conversion from the background). To encode the passed Chinese parameters and decode them when they are received.
>> to deliver
<script language= "JavaScript" >
function Gourl ()
{
var Name = "Chinese parameter";
Location.href = "B.aspx?" Name= "+escape (Name);
}
</script>
<body >
>> to receive
String Name = request.querystring["name"];
Response.Write (Server.urldecode (Name));

Generally speaking. You can set the Web.config file. But if you invoke the WebService method with JavaScript (the Chinese parameter is passed to the WebService). Setting the Web.config file appears to be invalid.

————————————————————
To implement codecs in HTML:

<script language= "JavaScript" >
function OpenURL (SRC)
{
var strurl=escape (SRC);
window.open (strURL);
}


function Change_url (SRC)
{
Document.location.href=escape (SRC);
}

</script>

Save in new window
<a href= ' Javascript:openurl ("css/contract. Doc"); ' > Delivery Contract </a>


The current position is saved without blinking.
<a href= "#" onclick=blocked scriptchange_url ("css/contract. Doc") > Contract </a>

Note: The slash in the path is: "/", not "\".


Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.