View Complete Thread
  • Re: ASP - Disable a button to prevent user from clicking twice

    Jan 22, 2014 02:49 AM|Angie xu - MSFT|LINK

    Hi

    According to your description above, you want to disable button to prevent double click in ASP, 

    Code in page(.aspx):

    <html xmlns="http://www.w3.org/1999/xhtml">
    <head runat="server">
        <title></title>
        <script language="javascript" type="text/javascript">
            var submit = 0;
            function CheckIsRepeat() {
                if (++submit > 1) {
                    alert('An attempt was made to submit this form more than once; this extra attempt will be ignored.');
                    return false;
                }
            }
        </script>
    </head>
    <body>
        <form id="form1" runat="server">
        <div>
            <asp:Button ID="Button1" runat="server" Text="Button" onclick="Button1_Click" OnClientClick="return CheckIsRepeat();" />
        </div>
        </form>
    </body>
    </html>

    For further information: Disable a button to avoid double clicks- http://forums.asp.net/t/1681765.aspx

    Best regards

    Angie

    Angie xu

    MSDN Community Support
    Please remember to "Mark as Answer" the responses that resolved your issue.