ALP Server.URLEncode method
URL Encodes a string

Syntax:

Server.URLEncode( string )

Parameters:

string - string to be encoded

The method returns new string containing URL encoded version of the passed to the method.

Examples:

JScript:

<A HREF="<%= Server.URLEncode("my.asp?a=" + aValue) %>">

VBScript:

<A HREF="<%= Server.URLEncode("my.asp?a=" & aValue) %>">

This method is useful to generate URLs from the scripts. If you are expecting the URL to include some symbols that can cause wrong interpretation of the values - use this method to encode the URL before the output.

Remarks:

In most cases you may avoid encoding of the first part of the URL and encoding is really required only for the parameters passed after the "?" sign. Thus the upper example lines can be changed to:

JScript:

<A HREF="<%= "my.asp?a=" + Server.URLEncode(aValue) %>">

VBScript:

<A HREF="<%= "my.asp?a=" & Server.URLEncode(aValue) %>">

Applies to: Server object

See also: Server.HTMLEncode, Response.Write

newObjects Copyright 2001-2006 newObjects [ ]