Setting The Textbox Read Only Property To True Using Javascript
How do you set the Textbox read only property to true or false using JavaScript in ASP.NET?
Solution 1:
You can try
document.getElementById("textboxid").readOnly = true;
Solution 2:
document.getElementById('textbox-id').readOnly=true
should work
Solution 3:
I find that document.getElementById('textbox-id').readOnly=true
sometimes doesn't work reliably.
Instead, try:
document.getElementById('textbox-id').setAttribute('readonly', 'readonly')
and
document.getElementById('textbox-id').removeAttribute('readonly')
.
A little verbose but it seems to be dependable.
Solution 4:
Try This :-
set Read Only False ( Editable TextBox)
document.getElementById("txtID").readOnly=false;
set Read Only true(Not Editable )
var v1=document.getElementById("txtID");
v1.setAttribute("readOnly","true");
This can work on IE and Firefox also.
Solution 5:
Using asp.net, I believe you can do it this way :
myTextBox.Attributes.Add("readonly","readonly")
Post a Comment for "Setting The Textbox Read Only Property To True Using Javascript"