Site icon David Yin's Blog

Server.Urlencode

Formats a string using URL encoding. This is a static method.
Syntax
urlEncode( text )
text
The input string to be formatted.
Usage
This method will format a string using URL encoding. The formatted string is returned from this method and the original string is not modified. This method is useful for encoding strings that contain any URL reserved characters so they can be used as part of a URL.
The example below encodes a string that is used as a query string parameter in a URL.
var sUrl = “http://localhost/app?user=” + Server.urlEncode(“john doe”);
Response.write(sUrl);
The example above produces the following output.
http://localhost/app?user=john+doe
This function is very useful when used in the URL transferring string which including space and special character like &.

Exit mobile version