468,103 Members | 1,328 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,103 developers. It's quick & easy.

How to fire validation in CreateUserWizard next button?

Hi All,

I am trying to do validation on my text field before going to the
next page to create a user. It doesn't look like the next button will
fire any validation. Am I missing something? Can anyone please help me
with this?

I am attaching my code piece. Thank you in advance for your help.

Wing

------ My Code Piece ------

<asp:CreateUserWizard ID="cuwCreateUser" runat="server"
OnCreatedUser="cuwCreateUser_CreatedUser" Width="90%"
OnNextButtonClick="cuwCreateUser_NextButtonClick">
<WizardSteps>
<asp:WizardStep runat="server" StepType="Start"
Title="Additional Information" ID="wsStep1">
<table border="0" style="font-size: 100%; width:
100%;">
<tr>
<td align="center" colspan="2">
<strong>Create New
User</strong></td>
</tr>
<tr>
<td style="text-align: right; width:
25%">First Name:</td>
<td align="left"><asp:TextBox
ID="txtFirstName" runat="server" Width="90%"></asp:TextBox>
<asp:RequiredFieldValidator
ID="FirstNameRequired" runat="server" ControlToValidate="txtFirstName"
ErrorMessage="First Name is
required." ToolTip="First Name is required."

ValidationGroup="cuwCreateUser">*</asp:RequiredFieldValidator></td>
</tr>
</table>
</asp:WizardStep>
<asp:CreateUserWizardStep runat="server" Title="Add
User">
<ContentTemplate>
<table border="0" style="font-size: 100%;
width: 100%">
<tr>
<td align="center" colspan="2">
<strong>Create New User (Con't)
</strong></td>
</tr>
<tr>
<td colspan="2">&nbsp;</td>
</tr>
<tr>
<td style="text-align: right; width:
25%">
<asp:Label ID="UserNameLabel"
runat="server" AssociatedControlID="UserName">Login
Name:</asp:Label></td>
<td style="width: 283px; text-align:
left">
<asp:TextBox ID="UserName"
runat="server" Width="90%"></asp:TextBox>
<asp:RequiredFieldValidator
ID="UserNameRequired" runat="server" ControlToValidate="UserName"
ErrorMessage="User Name is
required." ToolTip="User Name is required."
ValidationGroup="cuwCreateUser">*</asp:RequiredFieldValidator>
</td>
</tr>
<tr>
<td align="right">
<asp:Label ID="PasswordLabel"
runat="server"
AssociatedControlID="Password">Password:</asp:Label></td>
<td style="width: 283px; text-align:
left">
<asp:TextBox ID="Password"
runat="server" TextMode="Password" Width="90%"></asp:TextBox>
<asp:RequiredFieldValidator
ID="PasswordRequired" runat="server" ControlToValidate="Password"
ErrorMessage="Password is
required." ToolTip="Password is required."
ValidationGroup="cuwCreateUser">*</asp:RequiredFieldValidator>
</td>
</tr>
<tr>
<td align="right">
<asp:Label
ID="ConfirmPasswordLabel" runat="server"
AssociatedControlID="ConfirmPassword">Confirm
Password:</asp:Label></td>
<td style="width: 283px; text-align:
left">
<asp:TextBox ID="ConfirmPassword"
runat="server" TextMode="Password" Width="90%"></asp:TextBox>
<asp:RequiredFieldValidator
ID="ConfirmPasswordRequired" runat="server"
ControlToValidate="ConfirmPassword"
ErrorMessage="Confirm Password
is required." ToolTip="Confirm Password is required."

ValidationGroup="cuwCreateUser">*</asp:RequiredFieldValidator>
</td>
</tr>
<tr>
<td align="right">
<asp:Label ID="EmailLabel"
runat="server" AssociatedControlID="Email">E-mail:</asp:Label></td>
<td style="width: 283px; text-align:
left">
<asp:TextBox ID="Email"
runat="server" Width="90%"></asp:TextBox>
<asp:RequiredFieldValidator
ID="EmailRequired" runat="server" ControlToValidate="Email"
ErrorMessage="E-mail is
required." ToolTip="E-mail is required."
ValidationGroup="cuwCreateUser">*</asp:RequiredFieldValidator>
</td>
</tr>
<tr>
<td align="right">
<asp:Label ID="QuestionLabel"
runat="server" AssociatedControlID="Question">Security
Question:</asp:Label></td>
<td style="width: 283px; text-align:
left">
<asp:TextBox ID="Question"
runat="server" Width="90%"></asp:TextBox>
<asp:RequiredFieldValidator
ID="QuestionRequired" runat="server" ControlToValidate="Question"
ErrorMessage="Security question
is required." ToolTip="Security question is required."

ValidationGroup="cuwCreateUser">*</asp:RequiredFieldValidator>
</td>
</tr>
<tr>
<td align="right">
<asp:Label ID="AnswerLabel"
runat="server" AssociatedControlID="Answer">Security
Answer:</asp:Label></td>
<td style="width: 283px; text-align:
left">
<asp:TextBox ID="Answer"
runat="server" Width="90%"></asp:TextBox>
<asp:RequiredFieldValidator
ID="AnswerRequired" runat="server" ControlToValidate="Answer"
ErrorMessage="Security answer
is required." ToolTip="Security answer is required."

ValidationGroup="cuwCreateUser">*</asp:RequiredFieldValidator>
</td>
</tr>
<tr>
<td align="center" colspan="2">
<asp:CompareValidator
ID="PasswordCompare" runat="server" ControlToCompare="Password"

ControlToValidate="ConfirmPassword" Display="Dynamic" ErrorMessage="The
Password and Confirmation Password must match."

ValidationGroup="cuwCreateUser"></asp:CompareValidator>
</td>
</tr>
<tr>
<td align="center" colspan="2"
style="color: red">
<asp:Literal ID="ErrorMessage"
runat="server" EnableViewState="False"></asp:Literal>
</td>
</tr>
</table>
</ContentTemplate>
</asp:CreateUserWizardStep>
<asp:CompleteWizardStep runat="server">
<ContentTemplate>
<table border="0" style="font-size: 100%;
width: 410px">
<tr>
<td align="center" colspan="2">
<strong>
Complete</strong></td>
</tr>
<tr>
<td colspan="2">&nbsp;</td>
</tr>
<tr>
<td>
New user has been successfully
created.</td>
</tr>
<tr>
<td align="right" colspan="2">
<asp:Button ID="ContinueButton"
runat="server" CausesValidation="False" CommandName="Continue"
OnClick="ContinueButton_Click"
Text="Continue" ValidationGroup="cuwCreateUser" />
</td>
</tr>
</table>
</ContentTemplate>
</asp:CompleteWizardStep>
</WizardSteps>
</asp:CreateUserWizard>

Mar 5 '06 #1
2 8883
Hi Wing,

It seems to fire if you take out the ValidationGroup value, cuwCreateUser.

I wonder if this has something to do with it: "When you specify a value for
the ValidationGroup property, only the validation controls that are part of
the specified group are validated"

Ken

Microsoft MVP [ASP.NET]
<wi*********@yahoo.com> wrote in message
news:11**********************@e56g2000cwe.googlegr oups.com...
Hi All,

I am trying to do validation on my text field before going to the
next page to create a user. It doesn't look like the next button will
fire any validation. Am I missing something? Can anyone please help me
with this?

I am attaching my code piece. Thank you in advance for your help.

Wing

------ My Code Piece ------

<asp:CreateUserWizard ID="cuwCreateUser" runat="server"
OnCreatedUser="cuwCreateUser_CreatedUser" Width="90%"
OnNextButtonClick="cuwCreateUser_NextButtonClick">
<WizardSteps>
<asp:WizardStep runat="server" StepType="Start"
Title="Additional Information" ID="wsStep1">
<table border="0" style="font-size: 100%; width:
100%;">
<tr>
<td align="center" colspan="2">
<strong>Create New
User</strong></td>
</tr>
<tr>
<td style="text-align: right; width:
25%">First Name:</td>
<td align="left"><asp:TextBox
ID="txtFirstName" runat="server" Width="90%"></asp:TextBox>
<asp:RequiredFieldValidator
ID="FirstNameRequired" runat="server" ControlToValidate="txtFirstName"
ErrorMessage="First Name is
required." ToolTip="First Name is required."

ValidationGroup="cuwCreateUser">*</asp:RequiredFieldValidator></td>
</tr>
</table>
</asp:WizardStep>
<asp:CreateUserWizardStep runat="server" Title="Add
User">
<ContentTemplate>
<table border="0" style="font-size: 100%;
width: 100%">
<tr>
<td align="center" colspan="2">
<strong>Create New User (Con't)
</strong></td>
</tr>
<tr>
<td colspan="2">&nbsp;</td>
</tr>
<tr>
<td style="text-align: right; width:
25%">
<asp:Label ID="UserNameLabel"
runat="server" AssociatedControlID="UserName">Login
Name:</asp:Label></td>
<td style="width: 283px; text-align:
left">
<asp:TextBox ID="UserName"
runat="server" Width="90%"></asp:TextBox>
<asp:RequiredFieldValidator
ID="UserNameRequired" runat="server" ControlToValidate="UserName"
ErrorMessage="User Name is
required." ToolTip="User Name is required."
ValidationGroup="cuwCreateUser">*</asp:RequiredFieldValidator>
</td>
</tr>
<tr>
<td align="right">
<asp:Label ID="PasswordLabel"
runat="server"
AssociatedControlID="Password">Password:</asp:Label></td>
<td style="width: 283px; text-align:
left">
<asp:TextBox ID="Password"
runat="server" TextMode="Password" Width="90%"></asp:TextBox>
<asp:RequiredFieldValidator
ID="PasswordRequired" runat="server" ControlToValidate="Password"
ErrorMessage="Password is
required." ToolTip="Password is required."
ValidationGroup="cuwCreateUser">*</asp:RequiredFieldValidator>
</td>
</tr>
<tr>
<td align="right">
<asp:Label
ID="ConfirmPasswordLabel" runat="server"
AssociatedControlID="ConfirmPassword">Confirm
Password:</asp:Label></td>
<td style="width: 283px; text-align:
left">
<asp:TextBox ID="ConfirmPassword"
runat="server" TextMode="Password" Width="90%"></asp:TextBox>
<asp:RequiredFieldValidator
ID="ConfirmPasswordRequired" runat="server"
ControlToValidate="ConfirmPassword"
ErrorMessage="Confirm Password
is required." ToolTip="Confirm Password is required."

ValidationGroup="cuwCreateUser">*</asp:RequiredFieldValidator>
</td>
</tr>
<tr>
<td align="right">
<asp:Label ID="EmailLabel"
runat="server" AssociatedControlID="Email">E-mail:</asp:Label></td>
<td style="width: 283px; text-align:
left">
<asp:TextBox ID="Email"
runat="server" Width="90%"></asp:TextBox>
<asp:RequiredFieldValidator
ID="EmailRequired" runat="server" ControlToValidate="Email"
ErrorMessage="E-mail is
required." ToolTip="E-mail is required."
ValidationGroup="cuwCreateUser">*</asp:RequiredFieldValidator>
</td>
</tr>
<tr>
<td align="right">
<asp:Label ID="QuestionLabel"
runat="server" AssociatedControlID="Question">Security
Question:</asp:Label></td>
<td style="width: 283px; text-align:
left">
<asp:TextBox ID="Question"
runat="server" Width="90%"></asp:TextBox>
<asp:RequiredFieldValidator
ID="QuestionRequired" runat="server" ControlToValidate="Question"
ErrorMessage="Security question
is required." ToolTip="Security question is required."

ValidationGroup="cuwCreateUser">*</asp:RequiredFieldValidator>
</td>
</tr>
<tr>
<td align="right">
<asp:Label ID="AnswerLabel"
runat="server" AssociatedControlID="Answer">Security
Answer:</asp:Label></td>
<td style="width: 283px; text-align:
left">
<asp:TextBox ID="Answer"
runat="server" Width="90%"></asp:TextBox>
<asp:RequiredFieldValidator
ID="AnswerRequired" runat="server" ControlToValidate="Answer"
ErrorMessage="Security answer
is required." ToolTip="Security answer is required."

ValidationGroup="cuwCreateUser">*</asp:RequiredFieldValidator>
</td>
</tr>
<tr>
<td align="center" colspan="2">
<asp:CompareValidator
ID="PasswordCompare" runat="server" ControlToCompare="Password"

ControlToValidate="ConfirmPassword" Display="Dynamic" ErrorMessage="The
Password and Confirmation Password must match."

ValidationGroup="cuwCreateUser"></asp:CompareValidator>
</td>
</tr>
<tr>
<td align="center" colspan="2"
style="color: red">
<asp:Literal ID="ErrorMessage"
runat="server" EnableViewState="False"></asp:Literal>
</td>
</tr>
</table>
</ContentTemplate>
</asp:CreateUserWizardStep>
<asp:CompleteWizardStep runat="server">
<ContentTemplate>
<table border="0" style="font-size: 100%;
width: 410px">
<tr>
<td align="center" colspan="2">
<strong>
Complete</strong></td>
</tr>
<tr>
<td colspan="2">&nbsp;</td>
</tr>
<tr>
<td>
New user has been successfully
created.</td>
</tr>
<tr>
<td align="right" colspan="2">
<asp:Button ID="ContinueButton"
runat="server" CausesValidation="False" CommandName="Continue"
OnClick="ContinueButton_Click"
Text="Continue" ValidationGroup="cuwCreateUser" />
</td>
</tr>
</table>
</ContentTemplate>
</asp:CompleteWizardStep>
</WizardSteps>
</asp:CreateUserWizard>

Mar 5 '06 #2
Hi Ken,

Thanks, it works. Well, I have another question would like to ask.
I would like to do a database lookup to validate if the user entered an
existed First Name when the Next button being clicked. I found that
there is a OnNextButtonClick event and I have put code there for
validation. I have put a label for error message on the WizardStep page
to show error message when database validation failed. When I clicked
on the next button, the validation complete and the error message
becomes visible and the it moves on to the second page. How can I keep
the user in the first page with the error message?

Thanks,
Wing

Mar 6 '06 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

4 posts views Thread by Luis Esteban Valencia | last post: by
5 posts views Thread by Verde | last post: by
1 post views Thread by Chris Ashley | last post: by
2 posts views Thread by VB Programmer | last post: by
2 posts views Thread by Learner | last post: by
6 posts views Thread by Jon Paal | last post: by
1 post views Thread by Solo | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.