Html Encoding a string in .NET

vishalneeraj-24503
Posted by vishalneeraj-24503 under ASP.NET category on | Points: 40 | Views : 259
Html Encoding is basically converting Html tags in non Html tags so that they can be embeded into a html code.

string html_string = "<b>Hello world!</b>"; 
Response.Write(html_string);

Output:- Hello world!

string htmlEncoded = Server.HtmlEncode(html_string);
Response.Write(htmlEncoded);

Output:- <b>Hello world!</b>

Comments or Responses

Login to post response