Click here to Skip to main content
15,879,326 members
Articles / Web Development / HTML
Tip/Trick

ASP.NET Displaying HTML/HTML like content

Rate me:
Please Sign up or sign in to vote.
5.00/5 (3 votes)
17 Dec 2012CPOL 20.3K   10   1
Tip to display HTML/HTML like content as a text on your web page

Introduction

Sometimes we may need to display HTML like content on the web page. But the browser interprets such strings as HTML and starts rendering the page accordingly. This my lead to some undesired output.

For example :   We have the following text to be assigned to a label - "This is my <test string>" displayed as "This is my" but not "This is my <test string>" . This is because "<test string>" is interpreted as a HTML tag.

In-Order to display the desired string, we will have to perform a HTML encode on the string. 

C++
Server.HtmlEncode("This is my <test string>") 

This can also be helpful in displaying the HTML content literally on a webpage. 

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Software Developer
United States United States
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions

 
GeneralMy vote of 5 Pin
arh661-Jan-13 8:42
arh661-Jan-13 8:42 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.