0

I added one more submit button (Button1) to my changepasswordtemplate. I added the same validationgroup as original (ChangePasswordPushButton) to button1 but this one only validates/shows after Postback. The first one behaves as expected.

<asp:ChangePassword ID="ChangePwd" runat="server" >
        <ChangePasswordTemplate>
            <table cellpadding="1" style="border-collapse:collapse;">
                <tr>
                    <td>
                        <table cellspacing="5" cellpadding="5">
  
                            <tr>
                                <td align="right">
                                    <asp:Label ID="CurrentPasswordLabel" runat="server" AssociatedControlID="CurrentPassword">Password:</asp:Label>
                                </td>
                                <td>
                                    <asp:TextBox ID="CurrentPassword" runat="server" TextMode="Password"></asp:TextBox>
                                    <asp:RequiredFieldValidator ID="CurrentPasswordRequired" runat="server" ControlToValidate="CurrentPassword" ErrorMessage="Password is required." ToolTip="Password is required." ValidationGroup="ChangePwd">*</asp:RequiredFieldValidator>
                                </td>
                            </tr>
                            <tr>
                                <td align="right">
                                    <asp:Label ID="NewPasswordLabel" runat="server" AssociatedControlID="NewPassword">New Password:</asp:Label>
                                </td>
                                <td>
                                    <asp:TextBox ID="NewPassword" runat="server" TextMode="Password"></asp:TextBox>
                                    <asp:RequiredFieldValidator ID="NewPasswordRequired" runat="server" ControlToValidate="NewPassword" ErrorMessage="New Password is required." ToolTip="New Password is required." ValidationGroup="ChangePwd">*</asp:RequiredFieldValidator>
                                </td>
                            </tr>
                            <tr>
                                <td align="right">
                                    <asp:Label ID="ConfirmNewPasswordLabel" runat="server" AssociatedControlID="ConfirmNewPassword">Confirm New Password:</asp:Label>
                                </td>
                                <td>
                                    <asp:TextBox ID="ConfirmNewPassword" runat="server" TextMode="Password"></asp:TextBox>
                                    <asp:RequiredFieldValidator ID="ConfirmNewPasswordRequired" runat="server" ControlToValidate="ConfirmNewPassword" ErrorMessage="Confirm New Password is required." ToolTip="Confirm New Password is required." ValidationGroup="ChangePwd">*</asp:RequiredFieldValidator>
                                </td>
                            </tr>
                            <tr>
                                <td align="center" colspan="2">
                                    <asp:CompareValidator ID="NewPasswordCompare" runat="server" ControlToCompare="NewPassword" ControlToValidate="ConfirmNewPassword" Display="Dynamic" ErrorMessage="The Confirm New Password must match the New Password entry." ValidationGroup="ChangePwd"></asp:CompareValidator>
                                </td>
                            </tr>
                            <tr>
                                <td align="center" colspan="2" style="color:Red;">
                                    <asp:Literal ID="FailureText" runat="server" EnableViewState="False"></asp:Literal>
                                </td>
                            </tr>
                            <tr>
                                <td align="center">
                                    <asp:Button ID="ChangePasswordPushButton" class="orangeButton" runat="server" CommandName="ChangePassword" Text="Change Password" ValidationGroup="ChangePwd"/>
                                </td>
                                <td align="center">
                                    <asp:Button ID="CancelPushButton" class="orangeButton" runat="server" CausesValidation="False" CommandName="Cancel" Text="Cancel" />
                                </td>
                                <td align="center">
                                    <asp:Button ID="Button1" class="orangeButton" runat="server" CommandName="Upgrade" Text="Upgrade User Password" OnClick="Upgrade_Click" ValidationGroup="ChangePwd"/>
                                </td>
                            </tr>
                        </table>
                    </td>
                </tr>
            </table>
        </ChangePasswordTemplate>
  ...
</asp:ChangePassword>

What is the catch here? Button1 explicitly uses asp.net membership

MembershipUser.ChangePassword

whereas the other one has no code behind and just works!

Samra
  • 1,815
  • 4
  • 35
  • 71

0 Answers0