<div style="width:100%; background-color:Aqua; text-align:center; vertical-align:middle; height:30px;">
<asp:ValidationSummary ID="ValidationSummary1" runat="server" HeaderText="Error" />
</div>
如果没有错误,我不想显示 div 元素。我不想用js,只用asp控件!
<div style="width:100%; background-color:Aqua; text-align:center; vertical-align:middle; height:30px;">
<asp:ValidationSummary ID="ValidationSummary1" runat="server" HeaderText="Error" />
</div>
如果没有错误,我不想显示 div 元素。我不想用js,只用asp控件!
一种选择是创建新的 webcontrol 并从 ValidationSummary 派生它并覆盖 Render 方法,以便像您想要的那样用 div 包装您的真实 ValidationSummary。
protected override void Render(HtmlTextWriter output) {
writer.Write("<div class=\"validationsummary-wrap\">");
//Write the derived validation summary
base.Render(writer);
writer.Write("</div>");
}
使用height:auto; line-height:30px;
而不是height:30px;
<div style="width:100%; background-color:Aqua; text-align:center; vertical-align:middle; height:auto; line-height:30px;">
<asp:ValidationSummary ID="ValidationSummary1" runat="server" ForeColor="Black" HeaderText="Fill" />
</div>