Search code examples
.netasp.netasp.net-membershipcreateuserwizard

Server-side validation for CreateUserWizard


I am using the built-in asp.net membership framework. I created a registration page and set up client-side validation with some custom validators, validating through jQuery AJAX to a web service and the client-side validation works ok. I have two issues:

  1. Even when the client-side validation fails, the continue button still works. How do I disable it?

  2. I don't want to count on client-side validation. How do I go about implementing server-side validation in the CreateUserWizard? Can you point me at some specific tutorial? I failed to find one.

Thank you!


Solution

  • Use event CreatingUser.

    Markup:

    <asp:CreateUserWizard runat="server" CreatingUser="wizard_CreatingUser" />
    

    Code:

    protected void wizard_CreatingUser (object sender, LoginCancelEventArgs e)
    {
        e.Cancel = ((CreateUserWizard)sender).UserName.Contains("!@#$%^&");
    }