Server.Urlencode

| No Comments

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 usefull, when used in the url transfering string which including space and special character like &.




Leave a comment

About Me

As a tech geek and life geek, I always like to share my experience to you, my readers.

David Yin

About this Entry

This page contains a single entry by David Yin published on December 15, 2005 4:42 PM.

ATM Beware was the previous entry in this blog.

Code Convertor is the next entry in this blog.

Find recent content on the main index or look in the archives to find all content.

Archives

Subscribe

Ads