change password control problem

Last post 04-09-2006 12:10 AM by sbillingsley. 1 replies.

Sort Posts:

  • change password control problem

    04-07-2006, 6:07 PM
    • Participant
      1,214 point Participant
    • andieje
    • Member since 10-25-2005, 11:23 PM
    • Posts 381

    Hi

    I have a problem with my change password control. Firstly the required field validators are not triggered at all. The min/max length validators are triggered but the Change Password button still submits the page even if the min/max length validators have errors.

    Can you see what's wrong with it? I can't

    <ChangePasswordTemplate>
                  
                                <table border="0" cellpadding="0"
                                    style="font-family: Verdana;">
                                   
                                    <tr>
                                        <td align="right" style="height: 40px">
                                            <asp:Label
                                              AssociatedControlID="CurrentPassword"
                                              ID="CurrentPasswordLabel"
                                              runat="server">Password:</asp:Label>
                                              </td>
                                        <td style="width: 298px; height: 40px">
                                            <asp:TextBox ID="CurrentPassword"
                                              runat="server" TextMode="Password">
                                              </asp:TextBox>
                                            <asp:RequiredFieldValidator
                                              ControlToValidate="CurrentPassword"
                                                ErrorMessage="Password is required."
                                                ID="CurrentPasswordRequired"
                                                runat="server"
                                                ToolTip="Password is required."
                                                ValidationGroup="ChangePassword1" Display="Dynamic">Password is required.</asp:RequiredFieldValidator>
                                        </td>
                                    </tr>
                                    <tr>
                                        <td align="right">
                                            <asp:Label
                                              AssociatedControlID="NewPassword"
                                                ID="NewPasswordLabel"
                                                runat="server">New Password:
                                                </asp:Label></td>
                                        <td style="width: 298px">
                                            <asp:TextBox ID="NewPassword"
                                              runat="server" TextMode="Password">
                                             </asp:TextBox>
                                            <asp:RequiredFieldValidator
                                              ControlToValidate="NewPassword"
                                              ErrorMessage="New Password is required."
                                              ID="NewPasswordRequired"
                                              runat="server"
                                              ToolTip="New Password is required."
                                              ValidationGroup="ChangePassword1" Display="Dynamic">New Password is required.</asp:RequiredFieldValidator>
                                            <cc1:TextBoxLengthValidator ID="TextBoxLengthValidator1" runat="server" ControlToValidate="NewPassword"
                                                Display="Dynamic" MaxLength="255" MinLength="6" ValidationGroup="ChangePassword1">Password must be at least 6 characters</cc1:TextBoxLengthValidator></td>
                                    </tr>
                                    <tr>
                                        <td align="right">
                                            <asp:Label
                                              AssociatedControlID="ConfirmNewPassword"
                                              ID="ConfirmNewPasswordLabel"
                                               runat="server">Confirm New Password:
                                             </asp:Label>
                                         </td>
                                        <td style="width: 298px">
                                            <asp:TextBox ID="ConfirmNewPassword"
                                              runat="server"
                                              TextMode="Password">
                                             </asp:TextBox>
                                            <asp:RequiredFieldValidator
                                              ControlToValidate="ConfirmNewPassword"
                                              ErrorMessage="Confirm New Password is required."
                                              ID="ConfirmNewPasswordRequired"
                                              runat="server"
                                              ToolTip="Confirm New Password is required."
                                              ValidationGroup="ChangePassword1" Display="Dynamic">Confirm New Password is required.</asp:RequiredFieldValidator>
                                            <cc1:TextBoxLengthValidator ID="TextBoxLengthValidator2" runat="server" ControlToValidate="ConfirmNewPassword"
                                                Display="Dynamic" MaxLength="255" MinLength="6" ValidationGroup="ChangePassword1">Password must be at least 6 characters</cc1:TextBoxLengthValidator></td>
                                    </tr>
                                   
                                    <tr>
                                        <td align="center" colspan="2">
                                            <asp:CompareValidator
                                              ControlToCompare="NewPassword"
                                               ControlToValidate="ConfirmNewPassword"
                                                Display="Dynamic"
                                                ErrorMessage="The confirm New Password must match the New Password entry."
                                                ID="NewPasswordCompare"
                                                runat="server"
                                                ValidationGroup="ChangePassword1">
                                             </asp:CompareValidator>
                                        </td>
                                    </tr>
                                    <tr>
                                        <td align="center" colspan="2"
                                            style="color: Red;">
                                            <asp:Literal EnableViewState="False"
                                                ID="FailureText" runat="server">
                                            </asp:Literal>
                                        </td>
                                    </tr>
                                    <tr>
                                        <td align="right">
                                            <asp:ImageButton ID="ChangePassword" runat="server" CommandName="ChangePassword"
                                                ImageUrl="~/App_Themes/MainTheme/images/button_chgpassword.jpg" />&nbsp;</td>
                                        <td style="width: 298px">
                                            &nbsp;<asp:ImageButton ID="Cancel" runat="server" CommandName="Cancel" ImageUrl="~/App_Themes/MainTheme/images/button_cancel.jpg" /></td>
                                    </tr>
                                   
                                </table>
                  
                </ChangePasswordTemplate>
             
            </asp:ChangePassword>


    Thanks a lot
    andrea

  • Re: change password control problem

    04-09-2006, 12:10 AM
    • Member
      642 point Member
    • sbillingsley
    • Member since 04-17-2004, 7:36 PM
    • Des Moines, Iowa
    • Posts 121

    in the NextButtonClick or finishButtonClick, or whatever click event, first check if the page isValid and then exit the function, by using the return keyword, if it is not.

    e.g., 

        protected void Wizard1_NextButtonClick(object sender, WizardNavigationEventArgs e)
        {
            // re-validate using all of the validation controls
            if (!Page.IsValid)
            {
                e.Cancel = true;
                return;
            }

          ... etc...

        }

Page 1 of 1 (2 items)