views:

962

answers:

3

Greetings, I have a form where employees enter comments in a multiline textbox with a limit of 4000 characters. I have the rows set to 8 (obviously an arbitrary number).

When a supervisor looks at the comments the textbox is disabled so the employee comments cannot be modified.

The problem is when the data extends below row 8. Since the textbox is disabled the scrollbar cannot be moved and the supervisor cannot see all the comments. If I hide the textbox and databind to a label for the supervisor none of the line breaks are maintained and a well written paragraph turns into the biggest run on sentence ever…

Is there a way to enable the scroll bar leaving the text disabled?
Is there a way to preserve the structure of the entry in the label?

+2  A: 

In supervisor mode, don't put the text into a textbox, put it in a label as you mentioned, with '.Replace("\n", "<br>")' in your code.

Alternatively, show the textbox without disabling it, and just disable the 'save' button. Put a note on the page saying that, "changes made here are not persistent" or something to that effect.

Aric TenEyck
The Label/Replace worked like a charm...Set BorderStyle="Solid" BorderWidth="1" and it blends into the page...Thanks!!!
Dining Philanderer
+1  A: 

Put the text in a PRE tag, and apply overflow:scroll to it.

Make sure to escape the text using Server.HtmlEncode first.

EDIT: This will preserve spacing from the text box

SLaks
+4  A: 

Instead of disabling the textbox you should set the ReadOnly property to True. This keeps the scrollbars functional but doesn't allow modification of the textbox.

txtComments.ReadOnly = true;
Ahmad Mageed