The reason and solving method of the URL string code garbled in asp.net-practical skills

Source: Internet
Author: User

First look at the example

Copy Code code as follows:

function WebChart () {
var t = document.getElementById ("txtreceive");
if (T.value = null | | t.value = = "") {
Alert ("Please inquire first");
}
else {

alert (T.value);
document.getElementById ("Center-iframe"). src = "map/industrymap.aspx?_indeustry=" + t.value;
}}



This time alert comes out of the code is very normal, are Chinese characters.

But it's garbled when you get it in the background.

Copy Code code as follows:

protected void Page_Load (object sender, EventArgs e)
{
Industry = request.querystring["_indeustry"]. ToString ();

Initmap ();
Getshowmuilt ();
}

Web.config has been configured for UTF-8, but not yet.

Copy Code code as follows:

<system.web>
<globalization culture= "en-en" and "uiculture=" requestencoding= "UTF-8"
responseencoding= "UTF-8" fileencoding= "UTF-8"/>
</system.web>



Final Solution

Copy Code code as follows:

function WebChart () {
var t = document.getElementById ("txtreceive");
if (T.value = null | | t.value = = "") {
Alert ("Please inquire first");
}
else {
var url = encodeURI ("map/industrymap.aspx?_indeustry=" + t.value);
alert (URL);
document.getElementById ("Center-iframe"). src = URL;
}
}

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.