0

我正在使用如下所示的自定义 .net 验证器,自定义验证器仅在验证摘要中显示它的错误消息。我已经在验证摘要上设置了 CssClass,这可以正常工作并在 li 标签中呈现我的所有错误消息。我想要的是我的验证器之一在验证摘要中具有单独的样式,我尝试将值设置如下,但自定义验证器的 CssClass 从未反映在 HTML

<asp:CustomValidator ErrorMessage="Test error" ID="problemsLoggingIn" runat="server" Display="None" ValidationGroup="LoginValidationGroup" CssClass="specialCaseLi" ForeColor="" />

<asp:ValidationSummary ID="ValidationSummary1" DisplayMode="BulletList" CssClass="errorMsg" runat="server" ValidationGroup="LoginValidationGroup" />

给出这个 HTML:

<div id="ctl00_MainContentPlaceHolder_LoginView_LoginForm_ValidationSummary1" class="errorMsgDiv" style="color:Red;">
<ul><li>Test error</li></ul>
</div>
4

1 回答 1

0

Here is some CSS that will work:

enter code here.validation-summary-errors {
background-color: #D9FFB2;
border:1px solid #5CBA30;
width: 400px;
}
 span.validation-summary-errors {
border-bottom-color: #D9FFB2;
display:block;
}
     ul.validation-summary-errors {
margin:0;
padding:0;
border-top:none;
}

Check this link: Surrounding a ValidationSummary with a box via CSS

于 2012-06-18T11:26:33.087 回答