jqueryasp.netuser-controlstextboxhtml.textbox

Is This Possible? Make Certain Lines in a ASP.NET Textbox Read-Only


I have a textbox on my page to accept user input and I'd like to have a couple of line showing up as read-only WITHIN the textbox as hints. For example,

(read-only) Begin Input Category: User
....
....
....
....
(read-only) End Input Category: User

Is this even possible with some trick in jQuery or CSS?


Solution

  • No, you cannot make individual lines of a textbox read only.

    However, you could keep a seperate copy of the original text in a variable, and every time the user types in the textbox compare and if they touched the read only parts, fix it back, but this is likely to be error prone.

    A better choice would be something more like how masterpages work, where the master template defines user editable areas, and you provide a place for the user to input those user defined areas (seperate text boxes? XML delmited text?), then you can render a merged view