Saturday, 4 August 2012

ASP.NET Read Value using Javascript from Disabled Textbox.

If the asp:TextBox is Disabled so its a little tricky to read from Javascript.
There is actually no way to read the value from a disabled or hidden textbox from server side. But sometimes we need to prevent users from entering values to a textbox after some condition but access the already provided textbox value from the server side. For that, we can set the readonly property of the textbox to true. Setting it to true will not prevent server side from accessing it. It will just prevent end users from entering value to the textbox.


As for example, you can set it to readonly mode with following javascript code snippet.
document.getElementById(textboxID).readOnly = true;


Now you can access that textbox from server side even though it prevent end users from entering values.


Good Luck`

0 comments:

Post a Comment

Twitter Delicious Facebook Digg Stumbleupon Favorites More