ValidationSummary始终显示星号

时间:2013-06-13 12:22:14

标签: asp.net .net validation web requiredfieldvalidator

我为changepassword控件设置了以下设置:

<asp:ChangePassword ID="ChangePassword1" runat="server">
        <ChangePasswordTemplate>
            <h3>
                Password Management</h3>
            <asp:TextBox ID="CurrentPassword" runat="server" TextMode="Password" Style="display: none;"></asp:TextBox>
            <div class="field">
                <asp:Label ID="NewPasswordLabel" runat="server" AssociatedControlID="NewPassword">New Password:</asp:Label>
                <asp:TextBox ID="NewPassword" runat="server" TextMode="Password"></asp:TextBox>
                <asp:RequiredFieldValidator ID="NewPasswordRequired" runat="server" ControlToValidate="NewPassword" Display="Dynamic"
                    ErrorMessage="New Password" ToolTip="New Password is required."
                    ValidationGroup="ChangePassword1" EnableClientScript="false"></asp:RequiredFieldValidator>
            </div>
            <div class="field">
                <asp:Label ID="ConfirmNewPasswordLabel" runat="server" AssociatedControlID="ConfirmNewPassword">Confirm New Password:</asp:Label>
                <asp:TextBox ID="ConfirmNewPassword" runat="server" TextMode="Password"></asp:TextBox>

                <asp:RequiredFieldValidator ID="ConfirmNewPasswordRequired" runat="server" ControlToValidate="ConfirmNewPassword"
                    ErrorMessage="Confirm New Password" ToolTip="Confirm New Password is required." Display="Dynamic"
                    ValidationGroup="ChangePassword1" EnableClientScript="false"></asp:RequiredFieldValidator>
            </div>
            <div class="field">
                <asp:CompareValidator ID="NewPasswordCompare" runat="server" ControlToCompare="NewPassword"
                    ControlToValidate="ConfirmNewPassword" Display="Dynamic" ErrorMessage="The Confirm New Password must match the New Password entry."
                    ValidationGroup="ChangePassword1"></asp:CompareValidator>
            </div>

            <asp:ValidationSummary ID="ChangeUserPasswordValidationSummary" runat="server" CssClass="failureNotification" 
             ValidationGroup="ChangePassword1"/>


            <div class="action">
            <asp:Button ID="ChangePasswordPushButton" runat="server" CommandName="ChangePassword"
                Text="Change Password" ValidationGroup="ChangePassword1" />
            <asp:Button ID="CancelPushButton" runat="server" CausesValidation="False" CommandName="Cancel"
                Text="Cancel" Width="120" />
                </div>
        </ChangePasswordTemplate>
    </asp:ChangePassword>

当我点击ChangePasswordPushButton时,除了validationsummary显示2个星号之外,验证全部按预期工作!

任何人都知道为什么

2 个答案:

答案 0 :(得分:0)

我发现了问题所在。正在主题中设置错误消息!

哎呀

答案 1 :(得分:0)

尝试在所有验证器和ValidationSummary上添加以下代码:

EnableTheming="False"