Server-side validation for CreateUserWizard

2019-07-13 10:44发布

问题:

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!

回答1:

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("!@#$%^&");
}


回答2:

Please look on the following tutorials for full information about the CreateUserWizard: Customizing the CreateUserWizard Control.

Another helpful tutorial can be found here: Customizing ASP.NET's CreateUserWizard Control To Display a Fixed Set of Security Questions