How to display HTML contents How to display HTML contents Html Encode. Do you want to show HTML source content on page? It's simple with HttpUtility.HtmlEncode method. Here we will see both and examples of encoding HTML content for display. Html Encode.

Let's see C# HTML encode example.

protected void Page_Load(object sender, EventArgs e)
string htmlContent = "<b>This is bold string.</b><I>This is itallic string.</I>";

string htmlOutput = HttpUtility.HtmlEncode(htmlContent);

Response.Write("Html Content are: "+ htmlContent);
Response.Write("Html Source Content are: " + htmlOutput);
} Html Encode.

Protected Sub Page_Load(sender As Object, e As EventArgs)
Dim htmlContent As String = "<b>This is bold string.</b><I>This is itallic string.</I>"

Dim htmlOutput As String = HttpUtility.HtmlEncode(htmlContent)

Response.Write("Html Content are: " + htmlContent)
Response.Write("Html Source Content are: " + htmlOutput)
End Sub

This is very simple way of rendering the HTML content over browser. If html content are not encoded, browser display it as HTML.


html without using tables tableless html table less html css tableless layoutsBasic HTML5 Create Html ControlsC# HtmlTextWriter HTML5 Generate Article TagThis page contains secure and none secure information Do you want to display the none secure itemsDo you want to display nonsecure access html control textbox element value at code behindRegularExpression remove html tagsOnline html editor online JavaScript editorasp net image File Handling


My name is Satalaj, but people call me Sat. Here is my homepage: . I live in Pune, PN and work as a Software Engineer. I'm former MVP in year 2010.
Disclaimer: Views or opinion expressed here are my personal research and it has nothing to do with my employer. You are free to use the code, ideas/hints in your projects. However, you should not copy and paste my original content to other web sites. Feel free to copy or extend the code.
If you want to fight with me, this website is not for you.

I'm Satalaj.