Etienne
Etienne

Reputation: 7201

Remove HTML tags from string saved in database - ASP.NET

I am using ASP.NET 2.0 and SQL Server 2005.

I am saving a value/string in the database such as............

<P>Test 1</P><P>Test2</P>

Now i want to decode/remove the html tags and display it properly to the user such as....

Test 1

Test 2

I have tried this but it does not work!

txtDesc.Text = VALUE FROM DATABASE

What am i doing wrong? This must be a problem in ASP.NET 2.0?

Edit:

I am setting the value to a Text box where the TEXTMODE property of the text box is set to MULITILINE for scroll. Setting it to a normal Label work but not for my text box.......

Upvotes: 0

Views: 2429

Answers (2)

deerchao
deerchao

Reputation: 10544

ltrDesc.Text = Value from database

<div style="width:100px; height:100px; overflow:scroll">
    <asp:Literal ID="ltrDesc" runat="server" />
</div>

Upvotes: 1

Saar
Saar

Reputation: 8474

To display text with html tags, Literal, PlaceHolder, Panel server controls support better.

Upvotes: 0

Related Questions