Disabling ASPX Controls on client side

To enable or disable .Net controls on client side use following scripts.

//To Disable
document.getElementById(element_client_id).setAttribute('disabled','true');

//To Enable
document.getElementById(element_client_id).removeAttribute('disabled');

Nearly all html rendered control would adher to this coding guide, but aspx checkbox has a span element wrapped up on it. To disable checkbox properly add a extra line as below.

document.getElementById(element_client_id).parentElement.removeAttribute('disabled');

Leave a Reply

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.