Using JS in ASP encodeURIComponent method _ Application Technique

Source: Internet
Author: User
You know, in JS encodeURIComponent method is a more commonly used encoding method, but due to the work needs, in the ASP need to this method, check a lot of information, there is no good method, and finally used the following method, the basic solution to the problem.
Copy Code code as follows:

<%
Function aspencodeuricomponent (SSTR)
Aspencodeuricomponent = Myencodeuricomponent (SSTR)
%>
<script language= "javascript" type= "Text/javascript" runat= "Server" >
function Myencodeuricomponent (SSTR) {
Return encodeURIComponent (SSTR);
}
</script>
<%
End Function
%>

Note:

encodeURIComponent method
Encodes a text string as a valid component of a Uniform Resource Identifier (URI).

encodeURIComponent (encodeduristring)

The required encodeduristring parameter represents an encoded URI component.

Description
The encodeURIComponent method returns an encoded URI. If you pass the encoding result to decodeURIComponent, the original string is returned. Because the encodeURIComponent method encodes all characters, note that if the string represents a path, such as/folder1/folder2/default.html, the slash will also be encoded. This will not be valid when the encoding result is sent as a request to the Web server. If the string contains more than one URI component, use the encodeURI method to encode it.

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.