Skip to content Skip to sidebar Skip to footer

Client Side And Server Side Events Not Firing Simultaneously

I have a asp.net button control. My requirement is such that upon clicking the button, it should be disabled and fire a server side event simultaneously. I am disabling the button

Solution 1:

Keep what you have and also set the property UseSubmitBehavior="false". This will force the button to use the asp.net postback mechanism, rather than the inbuilt browser mechanism.

See here for more details

EDIT

Browsers as standard will always submit a form when you click on a <input type="submit"> control (which is what is rendered to the HTML when you use a <asp:Button>). ASP.NET uses this feature to initiate the postback to the server.

The problem you have is that if the button is disabled (like you are doing in your javascript) then the browser will not submit the form (i.e. the postback will not happen).

By using the attribute UseSubmitBehavior="false" you are telling ASP.NET to ignore the fact that browsers can do the submit themselves, and instead the button should use the JavaScript postback methods provided by ASP.NET (the same methods that are used on AutoPostback="true" for things like <asp:Checkbox> etc).

The javascript postback ignores the fact that you have just set the control as disabled,meaning the control will be disabled on screen but the postback will still happen.

I hope that makes sense

Post a Comment for "Client Side And Server Side Events Not Firing Simultaneously"