Monday, March 26, 2012

Confirmbuttonextender doesnt work with button with usesubmitbehavior=false

Just more of a warning, if you use a standard button with a confirmbuttonextender and you have the usesubmitbehavior property set to false, the button will still cause the postback even though the messagebox shows to confirm the action. The postback does not wait for the messagebox to be dismissed.

Hi Jrod111,

Yes, if the UseSubmitBehavior="false" , it will send a postback no matter which button you choose. Let's find why.

When UseSubmitBehavior="true" (or not setted), the Button will generate these html code on the client page:

<input type="submit" name="Button" value="Click Me" id="Button" />

But when UseSubmitBehavior="false", the generated html code just like this:

<input type="button" name="Button" value="Click Me" onclick="javascript:__doPostBack('Button','')" id="Button" />

So that's the reason.

Best regards,

Jonathan


Im aware of how the usesubmitbehavior uses javascript, but the confirmbuttonextender attaches to the onclick event. Im guessing its handler fires after the _doPostBack() call, so it never gets intercepted. Maybe there is a tweak you can do to the extender to get its to intercept the onclick first and cancel it if necessary.

No comments:

Post a Comment