Click here to Skip to main content
13,288,104 members (61,833 online)
Click here to Skip to main content
Add your own
alternative version

Tagged as


10 bookmarked
Posted 17 Dec 2012

ASP.NET Displaying HTML/HTML like content

, 17 Dec 2012
Rate this:
Please Sign up or sign in to vote.
Tip to display HTML/HTML like content as a text on your web page


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. 

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

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


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


About the Author

Rajesh Kuramdasu
Software Developer
United States United States
No Biography provided

You may also be interested in...


Comments and Discussions

GeneralMy vote of 5 Pin
arh661-Jan-13 9:42
memberarh661-Jan-13 9: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.

Permalink | Advertise | Privacy | Terms of Use | Mobile
Web04 | 2.8.171207.1 | Last Updated 17 Dec 2012
Article Copyright 2012 by Rajesh Kuramdasu
Everything else Copyright © CodeProject, 1999-2017
Layout: fixed | fluid