0

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

2
  • What about it doesn't work? It doesn't strip the tags? Does it do anything to the angle brackets (<>) or does it escape them? Commented Dec 12, 2009 at 8:27
  • It's not changing anything, it still just displays the WHOLE string Commented Dec 12, 2009 at 8:29

2 Answers 2

1
ltrDesc.Text = Value from database

<div style="width:100px; height:100px; overflow:scroll">
    <asp:Literal ID="ltrDesc" runat="server" />
</div>
Sign up to request clarification or add additional context in comments.

8 Comments

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.
Hi, try Literal control instead of Label.
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.
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
Then use a Textbox with Multiline = true and Readonly = true: txtDesc.Text = VALUE from DATABASE
|
0

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.