I have a form which, for the sake of isolating the problem, has about a dozen plain HTML checkboxes (not WebControls), all of which are disabled. They are inside an UpdatePanel.
I have a link which calls
__doPostBack('a-control','my-custom-argument');
Depending on the first argument I supply, the page may do a full postback or a partial one.
When I do a full postback, none of the checkbox values are submitted in the post (because they are disabled). This is the normal and thus desired behavior.
However, when it does a partial postback, the script collects all of the values from my checkboxes and submits them, without indicating which ones were disabled, which breaks my code.
It’s annoying and I would like it to behave consistently. Is there anyway to tell the .NET javascript handler to work the way the rest of the world does and not postback the values of disabled HTML form elements?
I can suggest two options:
1) You can remove the
nameattribute of disabled controls with JavaScript just before doing postback.2) Override
Sys.WebForms.PageRequestManager.getInstance()._onFormSubmitwith corrected version of code. Just copy implementation fromMicrosoftAjaxWebForms.debug.js, add a handling for thedisabledattribute and attach the corrected function to the existing PageRequestManager object:Sys.WebForms.PageRequestManager.getInstance()._onFormSubmit = function…
Then register this JS block as startup script. It’s important to get a correct order of rendered script blocks. I do a similar thing in my subclass of ScriptManager:
Works like a charm!