URL-based Chinese delivery solution

Source: Internet
Author: User

 

URL-based Chinese delivery solution
1. Set the Web. config file. < System . Web >  
 
< Globalization Requestencoding = "Gb2312" Responseencoding = "Gb2312" Culture = "ZH-CN" Fileencoding = "Gb2312"   />  
 
</ System. Web >
2. Before passing Chinese characters, encode the Chinese parameters to be passed and decode them upon receiving them.
> Transfer
String name = "Chinese parameter ";
Response. Redirect ("B. aspx? Name = "+ server. urlencode (name ));
> Receive
String name = request. querystring ["name"];
Response. Write (server. urldecode (name ));

3. If a Chinese parameter is transferred from the. html file to the. aspx 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 = "JavaScript" >  
Function Gourl ()
{
VaR Name =   " Chinese Parameters " ;
Location. href =   " B. aspx? Name = " + Escape (name );
}  
</ Script >  
< Body Onclick = "Gourl ()" >  
> Receive
String name = request. querystring ["name"];
Response. Write (server. urldecode (name ));

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.

Codec in HTML:

< Script Language = "JavaScript" >
Function Openurl (SRC)
{
VaRStrurl=Escape (SRC );
Window. Open (strurl );
}
 

Function Change_url (SRC)
{
Document. Location. href=Escape (SRC );
}
 
</ Script >
 
Save in new window
< A Href = 'Javascript: Openurl ("CSS/20040603123628transaction center tobacco leaf online concentrated transaction system contract .doc ");' > 20040603123628 transaction center online centralized transaction system contract </ A >
 
 
The current location is saved without blinking.
< A Href = "#" Onclick = Javascript: change_url ("CSS/20040603123628transaction center tobacco leaf online concentrated transaction system contract .doc ") > 20040603123628 transaction center online centralized transaction system contract </ A >
 
Note: The slash in the path is "/" rather than "\". Otherwise, it will not work.

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.