I have an html button, see below. When it's clicked and AutoEventWireup="true", the Save_Click click handler is fired twice. When AutoEventWireup="False", it fires once.
Why is it firing twice? The button is not registered twice and no code which is adding the event handler. Using master page and no Ajax.
<button id="Save" accesskey="v" type="submit" runat="server" onserverclick="Save_Click"></button>
And now (at least in .net 4) even better:
<button runat="server">
by default behaves as it has type="submit" (fires twice on click), so for it to work correctly, we should explicitly set type="button", i.e.:
<button id="ButtonSubscribe2" runat="server" type="button" onserverclick="Save_Click"></button>
Ok I found out that that an HTMLButton fires for the onserverclick event and for the type="submit". When I removed type="submit", it fires once. This quirky behavior took me a long time to discover!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With