Js Code:
Var pname = encodeuri ('<% = productname %> '));
C # code:
Encoding: var name = server. urlencode (request. querystring ["pname"]); decoding: var productname = server. urldecode (param [2]);
Note: web. config is also configured on the Internet:
<Globalization requestencoding = "gb2312" responseencoding = "gb2312"/>,
Encoding
Sender server. urlencode ("Chinese", encoding. getencoding ("gb2312 "));
Receiver server. urldecode (request ["key"], encoding. getencoding ("gb2312 "));
I do not recommend this. This solves the garbled characters but may cause garbled characters in other places. The default encoding is UTF-8, which is more widely used than gb2312.
Summary and Examples
If the html file passes Chinese parameters to the. asp tutorial x file (that is, url conversion is not performed using the redirect () method from the background ). Similarly, the passed Chinese parameters must be encoded and decoded upon receiving.
> Transfer
<Script language = "webpage effect">
Function gourl ()
{
Var name = "Chinese parameter ";
Location. href = "B. aspx? Name = "+ escape (name );
}
<Body onclick = "gourl ()">
> Receive
String name = request. querystring ["name"];
Response. write (server. urldecode (name ));
Summary:
In general. Set the web. config file. However, if you use javascript to call the webservice method (passing Chinese parameters to webservice ). The web. config file is invalid.