Click here to Skip to main content
65,938 articles
CodeProject is changing. Read more.
Articles
(untagged)

ASP.NET Displaying HTML/HTML like content

0.00/5 (No votes)
17 Dec 2012 2  
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. 

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

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

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here