how to set textbox readonly property true or false using javascript....in asp.net
A:
Using asp.net, I believe you can do it this way :
myTextBox.Attributes.Add("readonly","readonly")
Soufiane Hassou
2009-11-18 21:54:19
not working...do u have any other solution...
2009-11-18 22:12:11
Try lowercasing the "O" in readonly. Alternatively you could try using the "disabled" attribute with true and false values. The two attributes are only subtly different (http://www.w3.org/TR/REC-html40/interact/forms.html#adef-disabled).
Chris
2009-11-19 01:16:06
+1
A:
I like jquery for things like this, see example. Depending on how your asp.net application is written, you may need to register your javascript to get this to work properly.
Mtblewis
2009-11-18 21:56:05
A:
it depends on how you trigger the event. the key you are looking is textbox.clientid.
x.aspx code
<script type="text/javascript">
function disable_textbox(tid) {
var mytextbox = document.getElementById(tid);
mytextbox.disabled=false
}
</script>
code behind x.aspx.cs
string frameScript = "<script language='javascript'>" + "disable_textbox(" + tx.ClientID ");</script>";
Page.ClientScript.RegisterStartupScript(Page.GetType(), "FrameScript", frameScript);
Henry Gao
2009-11-18 22:04:22