Click here to Skip to main content
Click here to Skip to main content

ASP.NET Displaying HTML/HTML like content

By , 17 Dec 2012
 

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, 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

Sign Up to vote   Poor Excellent
Add a reason or comment to your vote: x
Votes of 3 or less require a comment

Comments and Discussions

 
You must Sign In to use this message board.
Search this forum  
    Spacing  Noise  Layout  Per page   
GeneralMy vote of 5memberarh661-Jan-13 8:42 
thancks

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

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