0

I tried to display some text in Textbox(multiple lines) using ASP.NET. But I found that multi-line Textbox (textarea) is HTML encoded, meaning that when I want to display:

a >= b; & c

It will be automatically converted to:

a & gt;= b; & amp; c

which is NOT natural for people to read. So is there any way that I can disable this auto-HTML encoding behavior and just display it naturally in the Textbox?

1
  • Can't reproduce the error. When the text is displayed, it's displayed normally. Only the output HTML is encoded. Are you actually getting the encoded text displayed? Commented Jul 11, 2011 at 14:56

2 Answers 2

2

If you are setting the text in the markup (.aspx), then what platon said is correct: .aspx is technically XML, so it has to conform to valid XML which means > is encoded as >, etc.

If you are setting the text in code-behind, (for example, textBox.Text = "") you could instead use an HtmlControls text area:

System.Web.UI.HtmlControls.HtmlTextArea textBox = new System.Web.UI.HtmlControls.HtmlTextArea();
textBox.Value = "a >= b; & c";
Sign up to request clarification or add additional context in comments.

1 Comment

Yes I'm setting the text in code-behind. And using HtmlControls textarea solved my problem! Thanks Justin!
1

As far as I understand, you are talking about the text in the aspx mark up, right? If so, you should not worry. The client side editor will display the text you need, i.e.:

a >= b; & c

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.