Disable button on submit using javascript to prevent double clicking

Disable button on submit instead of onclick

Use this code?

Button is not firing postBack because you have disabled this. The approach to avoid multiple postBack is to have two buttons side by side. Real and dummy. On first click hide/delete the real button and show the dummy one
<asp:Button ID="Button1" runat="server" Text="Button" OnClick="Button1_Click" ClientIDMode="Static" OnClientClick="disableButton();"/>

<asp:Button ID="ButtonDummy" runat="server" Text="Button" ClientIDMode="Static" OnClientClick='return false;' style="display:none;"/>
and JS:
function disableButton() {

 $("#Button1").hide();

 $("#ButtonDummy").show();

 return true;
 }
shareimprove this answer

Leave a Reply

Your email address will not be published. Required fields are marked *