HTML Text in a textarea tag

E

Ed Anady

Shouldn't a textarea render HTML formatted code? I'm placing a literal
control in a table cell by doing the following...

LiteralControl lc = new LiteralControl( );
lc.Text = String.Format("<textarea rows=\"10\" cols=\"80\"
readonly>{0}</textarea>", Server.HtmlEncode(sr.ReadToEnd()));

The file contains HTML formatted text (e.g. <b>Now is the time...</b>)
but displays literally as "<b>Now is the time...</b>" instead of bolded
text. I've tried not encoding the text but it makes no difference.

Any help is appreciated.
 
P

Paul Henderson

Shouldn't a textarea render HTML formatted code?

The <textarea> tag defines a multi-line text-box for entry of *plain*
text, not formatted HTML. If you know the data you're inserting is
'safe', can't you just make the LiteralControl contain a <div> wrapping
the HTML itself?
 
E

Ed Anady

The reason I was using a TextArea was to get the verticle scroll bar.
Is there a way with a Div tag to limit it's size and get the scroll bar?
 
P

Paul Henderson

The reason I was using a TextArea was to get the verticle scroll bar.
Is there a way with a Div tag to limit it's size and get the scroll bar?

Yes, with CSS styles. Set height, width and overflow for the <div>
style like this:

width: 100%;
height: 50px;
overflow-y: scroll;

Using overflow-y: auto; instead of the last should make the browser
only display the scroll bar when the content is too tall to fit.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,764
Messages
2,569,564
Members
45,039
Latest member
CasimiraVa

Latest Threads

Top