views:

286

answers:

2

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

+1  A: 
ltrDesc.Text = Value from database

<div style="width:100px; height:100px; overflow:scroll">
    <asp:Literal ID="ltrDesc" runat="server" />
</div>
deerchao
It works in ASP.NET 3.5 yes, but not in 2.0 for some reason, it displayed the HTML tags to the user as well in 2.0.
Etienne
Hi, try Literal control instead of Label.
deerchao
Literal Control works yes thanks, but I want to place the text inside a text box multiple rows so if the text is long the user must be able to scroll and you cant do this with a Literal control.
Etienne
Oh dear, i see it works fine with a normal label as well, just not when i place the value into a text box with the text mode = Multiline
Etienne
Then use a Textbox with Multiline = true and Readonly = true: txtDesc.Text = VALUE from DATABASE
deerchao
Just set textbox's text, you don't need a label.
deerchao
That is what i have, and it is not working.
Etienne
You can use a div with style="overflow:scroll" to make it scrollable.
deerchao
Thanks! I just found that i can add a scroll bar to a label as well by doing this <asp:Label ID="Label4" Style="overflow-y:scroll;" runat="server" Text="Label" Height="64px" Width="248px"></asp:Label>
Etienne
A: 

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

Saar