ASP.NET, Javascript, and enabling disabled controls via client side script

Thursday, October 7, 2004 6:36 AM

Just ran across a little delima: I have a handful of ASP.NET controls that are initially loaded in a disabled state. The Framework generates these controls (and their text descriptions) like this:


Well, when you try to disable the checkbox (or any control) using the standard JavaScript of:

document.all.AdminConsole_IsAreaCheckbox.disbaled = false;

It won’t completely disable it… and thus, the value won’t be sent down to the postback. What you need to do is enable the span as well… but the easiest way is just to rip out the disabled attributes all together:

document.all.AdminConsole_IsAreaCheckbox.removeAttribute(‘disabled’); document.all.AdminConsole_IsAreaCheckbox.parentElement.removeAttribute(‘disabled’);

comments powered by Disqus