Friday, 24 February 2012

.Net Beginners : How to write HTML text or Encoded text on the web page?

There are many cases when we need to display HTML text as HTML text without applying HTML formatting.

Syntax :
Server.HtmlEncode(string)


Example :
   lblProductName.Text = Server.HtmlEncode("<h1>Hi</h1>")


Output :
   <h1>Hi</h1>


Without out using of HtmlEncode method It will display Formatted HTML text.
 Example :
   lblProductName.Text = "<h1>Hi</h1>"


Output :
   Hi

No comments:

Post a Comment