ASP.net scrolling text box when disabled

Hi, I have a form in which employees enter comments in a multi-line text box with a limit of 4000 characters. I have strings equal to 8 (obviously an arbitrary number).

When an observer looks at comments, the text box is disabled, so the employee’s comments cannot be changed.

The problem is that the data expands below line 8. Since the text box is disabled, the scroll bar cannot be moved, and the supervisor cannot see all the comments. If I hide the text box and the data binding to the label for the supervisor, then none of the line breaks will be saved, and a well-written paragraph will turn into the biggest run in the sentence ever ...

Is there a way to enable the scroll bar while leaving the text disabled?
Is there a way to keep the record structure in a label?

+4
source share
4 answers

In supervisor mode, do not put text in a text field, put it in a shortcut, as you mentioned, with '.Replace ("\ n", "<br>")' in your code.

Alternatively, show the text box without disabling it, and simply disable the "Save" button. Put a note on the page that says “the changes made here are not permanent” or something like that.

+3
source

Instead of disabling the text field, you should set the ReadOnly property to True. This preserves the scroll functionality, but does not allow you to change the text field.

txtComments.ReadOnly = true; 
+16
source

Make the text field read-only and set the foreground color to the same shade of gray used in disabled text fields.

 <asp:TextBox ForeColor="#AFAFAF" ReadOnly="true" /> 
+2
source

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

First of all, avoid text using Server.HtmlEncode .

0
source

Source: https://habr.com/ru/post/1286763/


All Articles