2012-05-29

How to read the value from a disabled textbox

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.

1 comment:

Mahad said...

Very nice i was looking for it.. Good
thanks