Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to display a text (Html format) in a website (Asp.net C#)

I have a text editer, after applying format to the text I display the text when a button is clicked. I want the text to be displayed with all the formatting applied in the text editor.

 lbl_Subject.Text = Server.HtmlEncode(formattedtext);

but it is not displayed in the format applied instead it is displayed as

<p> This is Para 1</p> <p> this is Para 2</p> <p> <strong>this is bold</strong></p>

how can I display the text with all the format applied in text editor

Update i tried with literal

the result is

&lt;p&gt; This is Para 1&lt;/p&gt; &lt;p&gt; this is Para 2&lt;/p&gt; &lt;p&gt; &lt;strong&gt;this is bold&lt;/strong&gt;&lt;/p&gt;
like image 620
Mark Avatar asked Dec 14 '11 11:12

Mark


2 Answers

use div instead of label.

div1.InnerHtml=formattedtext;
like image 160
Chamika Sandamal Avatar answered Oct 02 '22 02:10

Chamika Sandamal


HtmlEncode makes sure that text is displayed correctly in the browser and not interpreted by the browser as HTML.

Try removing HtmlEncode or using HtmlDecode.

like image 35
Louis Waweru Avatar answered Oct 02 '22 01:10

Louis Waweru