ASP Server.HTMLEncode() Method
The ASP Server.HTMLEncode() Method is used to convert an HTML code to a string. It is used to encode form data and other client request data before using it in the web application. When the string to be encoded is not a double-byte character set, this method will convert the characters as given below:
- The less-than, greater-than, ampersand, and double-quote characters are converted to their respective entity names.
- Any ASCII code character whose code is greater-than or equal to 0x80 is converted to &#<number>, where the <number> portion is the ASCII character’s value.
When the string to be encoded is a double-byte character set, this method converts characters as given below:
- All the extended characters are converted.
- Any ASCII code character whose code is greater-than or equal to 0x80 is converted to &#<number>, where <number> is the ASCII character value.
Syntax:
Server.HTMLEncode( string )
Parameter Values: It contains a string value that specifies the HTML to be encoded as a string.
Example: The following code illustrates this method.
<% response.write(Server.HTMLEncode( "The Bold tag: <b>" )) %> |
Output: The script produces the following output in the encoded form
The Bold tag: <b>
The Web Browser displays the HTML as normal
The Bold tag: <b>
Contact Us