Sunday, December 12, 2010

Behaviour of disabled controls in

How to disable controls:
When we are developing web applications we need to disable/enable controls on the form. Controls which supports disabled are BUTTON, INPUT, OPTGROUP, OPTION, SELECT, and TEXTAREA.
Please do not try to disable a control which doesn’t support this attribute it may have weird behaviour.
We can set attribute disabled="disabled" OR $('#ctrlID').attr('disabled','disabled') OR
document.getElementById(' ctrlID'').setAttribute("disabled",'disabled');
We can enable controls by removing disabled from the elements.
What will change in behaviour of controls when you disable them?
If you are working with dynamic web application and you are disabling/enabling controls then you should remember some key effect of disabling control.
1) Disabled controls will not be posted when you submit form.
Because of this if you have changed value in disabled control dynamically by JavaScript. Then new value will not be posted back on the server and your server control will behave like normal html control.
Is there any way to submit disabled control?
In Asp.Net server side form control have one property called submitdisabledcontrols.
Setting submitdisabledcontrols="true" will submit disabled control values on the server.
Never disable hidden field controls.
Even though we set disabled hidden fields will not be submitted. So please keep in mind that you are not disabling hidden fields by knowing or unknowingly. Otherwise your may behave weird.


  1. gr8 stuff
    thanks for sharing the knowledge

  2. I read your blog very impressed seen this kind of important information’s. Really am interested to back to your blog again to gather some more information’s


Comments posted on ASP.Net Ajax Tutorials Blog are moderated and will be approved only if they are on-topic and not abusive. Please email me or my team for tech-support or blogging related questions. Avoid including website URLs in your comments - Thanks Author