1

I have created 2 steps in the createuserwizard. 1st step is for user to input in their particulars and 2nd step is for default login step (username, password, security q&a)..

The validator works fine at step 1, however it is not working in step 2. The error messages are not working..

here is the code:

  <asp:CreateUserWizard ID="CreateUserWizard1" 
            runat="server" 
            oncreateduser="CreateUserWizard1_CreatedUser"
            InvalidPasswordErrorMessage="Password length must be more than 8 characters." 
            ContinueDestinationPageUrl="~/Home.aspx" 
            DisplayCancelButton = "True" 
            CancelDestinationPageUrl="~/Home.aspx" 
            DisableCreatedUser="True" onsendingmail="CreateUserWizard1_SendingMail"
            >

            <WizardSteps>

             <asp:WizardStep ID="CreateUserWizardStep0" runat="server">

                    <table>
                        <tr >
                            <th class="style9">Register your account at BedOfRoses:</th>
                        </tr>

                        <tr>
                            <td class="style9">Name:</td>
                            <td>
                                <asp:TextBox runat="server" ID="CustName"/>
                                <asp:RequiredFieldValidator runat="server" ID="RequiredFieldValidator1" ControlToValidate="CustName"
                                     ErrorMessage="CustName is required." />
                            </td>
                        </tr> 
                        <tr>
                            <td class="style9">Contact Number:</td>
                            <td>
                                <asp:TextBox runat="server" ID="CustNum" />
                                <asp:RequiredFieldValidator runat="server" ID="RequiredFieldValidator2" ControlToValidate="CustNum"
                                     ErrorMessage="CustNum is required." />
                            </td>
                        </tr>  
                        <tr>
                            <td class="style9">Cust Role:</td>
                            <td>
                                <asp:DropDownList ID="CustRole" runat="server">
                                    <asp:ListItem></asp:ListItem>
                                    <asp:ListItem>Bride</asp:ListItem>
                                    <asp:ListItem>Groom</asp:ListItem>
                                </asp:DropDownList>
                                <asp:RequiredFieldValidator runat="server" ID="RequiredFieldValidator3" ControlToValidate="CustRole"
                                     ErrorMessage="CustRole is required."  />
                            </td>
                        </tr>   
                        <tr>
                            <td class="style9">CustStatus:</td>
                            <td>
                                <asp:DropDownList ID="CustStatus" runat="server">
                                    <asp:ListItem></asp:ListItem>
                                    <asp:ListItem>Engaged</asp:ListItem>
                                    <asp:ListItem>Engaged, started planning</asp:ListItem>
                                    <asp:ListItem>Married!</asp:ListItem>
                                </asp:DropDownList>
                                <asp:RequiredFieldValidator runat="server" ID="RequiredFieldValidator4" ControlToValidate="CustStatus"
                                     ErrorMessage="CustStatus is required." />
                            </td>
                        </tr>     
                                <tr>
                            <td class="style9">PName:</td>
                            <td>
                                <asp:TextBox runat="server" ID="PName" />
                                <asp:RequiredFieldValidator runat="server" ID="RequiredFieldValidator5" ControlToValidate="PName"
                                     ErrorMessage="PName is required." />
                            </td>
                        </tr>
                                <tr>
                            <td class="style9">PEmail:</td>
                            <td>
                                <asp:TextBox runat="server" ID="PEmail" />
                                <asp:RequiredFieldValidator runat="server" ID="RequiredFieldValidator6" ControlToValidate="PEmail"
                                     ErrorMessage="PEmail is required." />
                            </td>
                        </tr>
                                <tr>
                            <td class="style9">PRole:</td>
                            <td>
                                <asp:DropDownList ID="PRole" runat="server">
                                    <asp:ListItem></asp:ListItem>
                                    <asp:ListItem>Bride</asp:ListItem>
                                    <asp:ListItem>Groom</asp:ListItem>
                                </asp:DropDownList>
                                <asp:RequiredFieldValidator runat="server" ID="RequiredFieldValidator7" ControlToValidate="PRole"
                                     ErrorMessage="PRole is required." />
                            </td>
                        </tr>
                                <tr>
                            <td class="style9">WedDate:</td>
                            <td>
                               <asp:ScriptManagerProxy ID="ScriptManagerProxy1" runat="server">
                                </asp:ScriptManagerProxy>

                                <asp:TextBox runat="server" ID="WedDate"/> &nbsp;
                                <asp:Label ID="Label1" 
                                    runat="server" style="font-size: small; text-decoration: underline" 
                                    Text="Wedding Date? " onmouseout="BalloonPopupControlBehavior.hidePopup();">
                                </asp:Label>

                                <asp:BalloonPopupExtender ID="Label1_BalloonPopupExtender" runat="server" 
                                    BalloonSize="Small" BalloonStyle="Rectangle" DisplayOnClick="False" 
                                    DisplayOnMouseOver="True" Enabled="True" 
                                    ExtenderControlID="" Position="TopRight" TargetControlID="Label1" 
                                    BalloonPopupControlID="Panel1" UseShadow="False" CustomClassName="Balloon">
                                </asp:BalloonPopupExtender>
                                <br /> 

                                  <asp:CalendarExtender ID="WedDate_CalendarExtender" runat="server" 
                                    DefaultView="Days" Enabled="True" PopupPosition="BottomLeft" 
                                    TargetControlID="WedDate" FirstDayOfWeek="Monday" CssClass="DatePicker" 
                                     Format="dd/MM/yyyy" >
                                </asp:CalendarExtender>

                                <asp:Panel ID="Panel1" runat="server">
                                    <span class="style5"><span class="style6"><em>Brides and Grooms: Don’t know your 
                                    exact wedding date yet?
                                    <br />
                                    Don’t worry, just put in an estimate – you can update it anytime.</em></span></span> 

                                 <asp:UpdatePanel ID="UpdatePanel1" runat="server">
                                    </asp:UpdatePanel>
                                </asp:Panel>

                                <asp:RequiredFieldValidator runat="server" ID="RequiredFieldValidator8" ControlToValidate="WedDate"
                                     ErrorMessage="WedDate is required." />
                            </td>
                        </tr>


                    </table>

                   </asp:WizardStep>



             <asp:CreateUserWizardStep ID="CreateUserWizardStep1" runat="server">
              <ContentTemplate>

                    <table>
                        <tr>
                            <th class="style4">User Information</th>
                        </tr>
                        <tr>
                            <td class="style4">Username:</td>
                            <td>
                                <asp:TextBox runat="server" ID="UserName" />

                                <asp:RequiredFieldValidator runat="server" ID="RequiredFieldValidator9" ControlToValidate="UserName" 
                                    ErrorMessage="Username is required." />
                            </td>
                        </tr>
                        <tr>
                            <td class="style4">Password:</td>
                            <td>
                                <asp:TextBox runat="server" ID="Password" TextMode="Password" MaxLength="20" />

                                <asp:RequiredFieldValidator runat="server" ID="RequiredFieldValidator10" ControlToValidate="Password" 
                                    ErrorMessage="Password is required." />
                            </td>
                        </tr>
                        <tr>
                            <td class="style4">Confirm Password:</td>
                            <td>
                                <asp:TextBox runat="server" ID="ConfirmPassword" TextMode="Password" />
                                <asp:RequiredFieldValidator runat="server" ID="RequiredFieldValidator13" ControlToValidate="ConfirmPassword" 
                                    ErrorMessage="Confirm Password is required." />
                            </td>
                        </tr>
                        <tr>
                            <td class="style4">Email:</td>
                            <td>
                                <asp:TextBox runat="server" ID="Email" />
                                <asp:RequiredFieldValidator ID="RequiredFieldValidator11" runat="server" ControlToValidate="Email" ErrorMessage="RequiredFieldValidator"></asp:RequiredFieldValidator>
                            </td>
                        </tr>
                        <tr>
                            <td class="style4">Question:</td>
                            <td>
                                <asp:DropDownList ID="Question" runat="server" Height="17px" Width="235px">
                                    <asp:ListItem></asp:ListItem>
                                    <asp:ListItem>What&#39;s the company name of your first job? </asp:ListItem>
                                    <asp:ListItem>Where did you first met your partner? </asp:ListItem>
                                    <asp:ListItem>What was your childhood nickname? </asp:ListItem>
                                    <asp:ListItem>Which primary school did you attend?</asp:ListItem>
                                </asp:DropDownList>
                                <asp:RequiredFieldValidator runat="server" ID="RequiredFieldValidator12" ControlToValidate="Question" 
                                    ErrorMessage="Question is required." />
                            </td>
                        </tr>
                        <tr>
                            <td class="style4">Answer:</td>
                            <td>
                                <asp:TextBox runat="server" ID="Answer" />
                                <asp:RequiredFieldValidator runat="server" ID="RequiredFieldValidator14" ControlToValidate="Answer" 
                                    ErrorMessage="Answer is required." />
                            </td>
                        </tr>
                        <tr>
                            <td colspan="2">
                                 <asp:CompareValidator ID="PasswordCompare" runat="server" ControlToCompare="Password"
                                        ControlToValidate="ConfirmPassword" Display="Dynamic" ErrorMessage="The Password and Confirmation Password must match."></asp:CompareValidator>
                            </td>
                        </tr>
                        <tr>
                            <td colspan="2">
                                <asp:Literal ID="ErrorMessage" runat="server" EnableViewState="False"></asp:Literal>
                            </td>
                        </tr>
                    </table>
                    <asp:SqlDataSource ID="InsertExtraInfo" runat="server" ConnectionString="<%$ ConnectionStrings:ASPNETDBConnectionString1 %>"
                        InsertCommand="INSERT INTO [Details] ([UserId], [CustName], [CustNum], [CustRole], [CustStatus], [PName], [PEmail], [PRole], [WedDate]) VALUES (@UserId, @CustName, @CustNum, @CustRole, @CustStatus, @PName, @PEmail, @PRole, @WedDate)"
                        ProviderName="<%$ ConnectionStrings:ASPNETDBConnectionString1.ProviderName %>">
                        <InsertParameters>
                            <asp:ControlParameter Name="CustName" Type="String" ControlID="CustName" PropertyName="Text" />
                            <asp:ControlParameter Name="CustNum" Type="String" ControlID="CustNum" PropertyName="Text" />
                            <asp:ControlParameter Name="CustRole" Type="String" ControlID="CustRole" PropertyName="Text" />
                            <asp:ControlParameter Name="CustStatus" Type="String" ControlID="CustStatus" PropertyName="Text" />
                            <asp:ControlParameter Name="PName" Type="String" ControlID="PName" PropertyName="Text" />
                            <asp:ControlParameter Name="PEmail" Type="String" ControlID="PEmail" PropertyName="Text" />
                            <asp:ControlParameter Name="PRole" Type="String" ControlID="PRole" PropertyName="Text" />
                            <asp:ControlParameter Name="WedDate" Type="String" ControlID="WedDate" PropertyName="Text" />
                        </InsertParameters>

                    </asp:SqlDataSource>
                    </ContentTemplate>

              </asp:CreateUserWizardStep>
4

1 回答 1

1

您应该在 RequiredField Validtors 中使用 Display="Dynamic" 并将 Validation Group 应用于您的控件。

于 2012-07-23T06:13:55.957 回答