How to make some part of textbox text to read only and other part to be editable
-
I have a textbox having textmode 'multiline' in which one can write source code, so my requirement is to make some part of textbox text to be read only and some part to be editable.....Suppose in a textbox there is 1 to 10 line(no of rows)... so i want row no.1 to row no.3 to be raedonly means no one can edit these rows, next row no.4 to row no.7 to be editable, and again row no.8 to row no.10 to read only. How to achieve the above requirement... ?? Appreciates your reply and Thanks in Advance :)
-
I have a textbox having textmode 'multiline' in which one can write source code, so my requirement is to make some part of textbox text to be read only and some part to be editable.....Suppose in a textbox there is 1 to 10 line(no of rows)... so i want row no.1 to row no.3 to be raedonly means no one can edit these rows, next row no.4 to row no.7 to be editable, and again row no.8 to row no.10 to read only. How to achieve the above requirement... ?? Appreciates your reply and Thanks in Advance :)
I wouldn't be suprised if there is no solution using a textbox. This almost sounds like it would be better as a grid control. You can perform much finer access control in a grid. Good luck.
-
I have a textbox having textmode 'multiline' in which one can write source code, so my requirement is to make some part of textbox text to be read only and some part to be editable.....Suppose in a textbox there is 1 to 10 line(no of rows)... so i want row no.1 to row no.3 to be raedonly means no one can edit these rows, next row no.4 to row no.7 to be editable, and again row no.8 to row no.10 to read only. How to achieve the above requirement... ?? Appreciates your reply and Thanks in Advance :)
I'll make the assumption that any line which can be edited cannot be broken into multiple lines... Use JavaScript to listen for any change/key press/etc events. Also, use JavaScript to store the original text in an array (it will also store if a line is read only). Any time the text changes, check to ensure that any read only lines did not change. If they did, modify those lines so they are back to their original. When the textbox is submitted back to the server, have your C# or VB.Net code do the same check as the JavaScript (in case the JavaScript was bypassed). As somebody else mentioned, it would be much easier to use another control, such as a grid view (or repeater), to split each line into its own control. That will allow you, for example, to more clearly indicate which lines are editable and which are read only (e.g., by graying out the read only lines).
-
I'll make the assumption that any line which can be edited cannot be broken into multiple lines... Use JavaScript to listen for any change/key press/etc events. Also, use JavaScript to store the original text in an array (it will also store if a line is read only). Any time the text changes, check to ensure that any read only lines did not change. If they did, modify those lines so they are back to their original. When the textbox is submitted back to the server, have your C# or VB.Net code do the same check as the JavaScript (in case the JavaScript was bypassed). As somebody else mentioned, it would be much easier to use another control, such as a grid view (or repeater), to split each line into its own control. That will allow you, for example, to more clearly indicate which lines are editable and which are read only (e.g., by graying out the read only lines).
I would say better would be using one from tone of JS libs, and RegExp on server but it's just my opinion. Also if customer would allow this with his browsers HTML5 masked textbox would be good solution to.
No more Mister Nice Guy... >: |
-
I have a textbox having textmode 'multiline' in which one can write source code, so my requirement is to make some part of textbox text to be read only and some part to be editable.....Suppose in a textbox there is 1 to 10 line(no of rows)... so i want row no.1 to row no.3 to be raedonly means no one can edit these rows, next row no.4 to row no.7 to be editable, and again row no.8 to row no.10 to read only. How to achieve the above requirement... ?? Appreciates your reply and Thanks in Advance :)
-
Thanks all for ur reply