Open In App

ASP Server.HTMLEncode() Method

Last Updated : 05 Feb, 2021
Improve
Improve
Like Article
Like
Save
Share
Report

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: &lt;b&gt;

The Web Browser displays the HTML as normal

The Bold tag: <b>

Like Article
Suggest improvement
Previous
Next
Share your thoughts in the comments

Similar Reads