asp:ValidationSummary in div elemenet and styled

<div style="width:100%; background-color:Aqua; text-align:center; vertical-align:middle; height:30px;">
<asp:ValidationSummary ID="ValidationSummary1" runat="server" HeaderText="Error" />
</div>

i dont want to show div element if has no error . i dont want to use js, just with asp controls !

Answers


One option is to create new webcontrol and derive it from ValidationSummary and override Render method, so to wrap your real ValidationSummary with div just like you want.

protected override void Render(HtmlTextWriter output) {
   writer.Write("<div class=\"validationsummary-wrap\">");

   //Write the derived validation summary
   base.Render(writer);

   writer.Write("</div>");
}

use height:auto; line-height:30px; instead of 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>

Need Your Help

RichTextBox Help saving *custom* links

c# hyperlink richtextbox customization

I have implemented arbitrary links in my rtb using the CodeProject found here. The links are not truly links but instead data that is looked up when clicked and returned expanded information on the...

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.