ASP.NET: ValidationSummary For A CreateUserWizard Control

ASP.NET provides a control that uses the Membership API to create users on the fly via the CreateUserWizard control. The only drawback with this control is that you cannot include any other details like first name, last name, address and others. You would have to place all other details as a separate page, called a Wizard Step. When you use forms, naturally, you would have to use validation in order to have the correct data that will be stored in your database.

ASP.NET also has a nifty control called ValidationSummary that collects all errors of controls found in the tag and displays them as either a List or a Bulleted List. I typically got stuck for half a day looking for a solution because my ValidationSummary control does not display when it is in the CreateUserStep of my wizard. You can use a property called ValidationGroup to specify which set of controls will be collected by the ValidationSummary control for display. You do this by giving the ValidationGroup a name, which is case-sensitive by the way. My problem persisted because the ValidationSummary control for my CreateUserStep has a different name. I later found out that you would have to use the CreateUserWizard’s ID as the ValidationSummary’s ValidationGroup’s name for this to work. See the sample code below.

Add User

<asp:ValidationSummary runat=”server” ID=”InfoVS”
ShowSummary=”true” DisplayMode=”BulletList” ValidationGroup=”PersonalVG”
HeaderText=”Please review the following errors:
<asp:ValidationSummary runat=”server” ID=”AddUserVS”
ShowSummary=”true” DisplayMode=”BulletList” ValidationGroup=”AddUserWizard”
HeaderText=”Please review the following errors:

first name
confirm password

Your account has been successfully created.

I specifically added a StartNavigationTemplate tag and overrode the asp:Button and its properties because the validation does not work if you do not set the button’s CausesValidation property to true. Hence, your ValidationSummary control would show nothing since no validation took place. Notice that my ValidationSummary’s ValidationGroup is called PersonalVG. You can name it any way you want but to use the ValidationSummary’s ValidationGroup for the CreateUserStep, you would have to use the CreateUserWizard’s ID for this to work. Otherwise, no validation error messages will be displayed and you will just be stuck on the CreateUserStep page.

Sorry, comments are closed for this post.