Preventing a user from clicking twice on createUserWizard

180 Views Asked by At

Occasionally, I somehow get a user that gets registered twice in asp.net web app. the registration uses the createUserwizard, and users and emails are set to unique, so I have no clue and have had no luck getting an answer on that in another post, so I have moved to another way to solve this. I think it might be from the user click the 'register' button twice close together. I have been trying many solutions to either disable the button after click (that is tough b/c of validation of fields), or popup a not saying "creating user', or even just change the button text to 'creating', like this solution --with no luck (Rory's). I do not get an error with this, but no button change happens. Here is my wizard (took out the EUA, chk box pass hint)

<WizardSteps>
    <asp:CreateUserWizardStep runat="server" ID="RegisterUserWizardStep" >
        <ContentTemplate>
            <p class="message-info">Passwords are required to be a minimum of <%: Membership.MinRequiredPasswordLength %> characters in length.</p>
            <p class="validation-summary-errors">
                <asp:Literal runat="server" ID="ErrorMessage" />
            </p>
            <fieldset>
                <legend>Registration Form</legend>
                <ol>
                    <li>
                        <asp:Label runat="server" AssociatedControlID="UserName">User name</asp:Label>
                        <asp:TextBox runat="server" ID="UserName" />
                        <asp:RequiredFieldValidator runat="server" ControlToValidate="UserName"
                            CssClass="field-validation-error" ErrorMessage="The user name field is required." />
                        <asp:RegularExpressionValidator runat="server" ControlToValidate="UserName"
                            CssClass="field-validation-error" ErrorMessage="No spaces or special characters" ValidationExpression="^[a-zA-Z0-9]+$" />
                    </li>
                    <li>
                        <asp:Label runat="server" AssociatedControlID="Email">Email address</asp:Label>
                        <asp:TextBox runat="server" ID="Email" TextMode="Email" />
                        <asp:RequiredFieldValidator runat="server" ControlToValidate="Email"
                            CssClass="field-validation-error" ErrorMessage="The email address field is required." />
                    </li>
                    <li>
                        <asp:Label runat="server" AssociatedControlID="Password">Password</asp:Label>
                        <asp:TextBox runat="server" ID="Password" TextMode="Password" />
                        <asp:RequiredFieldValidator runat="server" ControlToValidate="Password"
                            CssClass="field-validation-error" ErrorMessage="The password field is required." />
                    </li>
                    <li>
                        <asp:Label runat="server" AssociatedControlID="ConfirmPassword">Confirm password</asp:Label>
                        <asp:TextBox runat="server" ID="ConfirmPassword" TextMode="Password" />
                        <asp:RequiredFieldValidator runat="server" ControlToValidate="ConfirmPassword"
                             CssClass="field-validation-error" Display="Dynamic" ErrorMessage="The confirm password field is required." />
                        <asp:CompareValidator runat="server" ControlToCompare="Password" ControlToValidate="ConfirmPassword"
                             CssClass="field-validation-error" Display="Dynamic" ErrorMessage="The password and confirmation password do not match." />
                    </li>
                </ol>
                <asp:Button ID="registerBtn" runat="server" CommandName="MoveNext" Text="Register" " />
            </fieldset>
        </ContentTemplate>
        <CustomNavigationTemplate />
    </asp:CreateUserWizardStep>
</WizardSteps>

Any help preventing this x2 click would be greatly appreciated--it keeps breaking my ability to use the asp console tool when I get the "[user] key already exists" error.

1

There are 1 best solutions below

3
On

Can you disable the button after it is clicked once?

Public Class _Default
    Inherits Page
    Protected Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
        Button1.Enabled = False
        MsgBox("Next time you click, the button is disabled, and you don't get this message.")
    End Sub
End Class