<abc:ValidationSummary runat="server" ValidationGroup="MainValidationGroup" />
Namespace AmericanBroomCompany Public Class ValidationSummary Inherits System.Web.UI.WebControls.ValidationSummary Public Sub New() EnableClientScript = True HeaderText = "<b><center>Please correct the following item(s).</center></b>" ShowMessageBox = False ShowSummary = True DisplayMode = ValidationSummaryDisplayMode.BulletList BackColor = System.Drawing.Color.FromArgb(255, 255, 153) BorderColor = System.Drawing.Color.Red BorderWidth = New Unit(2D, UnitType.Pixel) Font.Bold = False Font.Size = New FontUnit(9) End Sub Public ReadOnly Property ErrorSummary() As String Get Dim result As String = "" For Each v As BaseValidator In Me.Page.Validators If v.ValidationGroup = Me.ValidationGroup And Not v.IsValid Then Select Case Me.DisplayMode Case ValidationSummaryDisplayMode.BulletList result &= "<li>" & v.ErrorMessage & "</li>" Case ValidationSummaryDisplayMode.List result &= v.ErrorMessage & "<br/>" Case ValidationSummaryDisplayMode.SingleParagraph result &= v.ErrorMessage & " " End Select End If Next Return result End Get End Property End Class End Namespace
namespace AmericanBroomCompany { public class ValidationSummary : System.Web.UI.WebControls.ValidationSummary { public ValidationSummary() { this.EnableClientScript = true; this.HeaderText = "<b><center>Please correct the following item(s).</center></b>"; this.ShowMessageBox = false; this.ShowSummary = true; this.DisplayMode = ValidationSummaryDisplayMode.BulletList; this.BackColor = System.Drawing.Color.FromArgb(255,255,153); this.BorderColor = System.Drawing.Color.Red; this.BorderWidth = new Unit(2D, UnitType.Pixel); this.Font.Bold = false; this.Font.Size = new FontUnit(9); } public string ErrorSummary { get { string result = ""; foreach (BaseValidator v in this.Page.Validators) { if (v.ValidationGroup == this.ValidationGroup & !v.IsValid) { switch (this.DisplayMode) { case ValidationSummaryDisplayMode.BulletList: result += "<li>"; result += v.ErrorMessage; result += "</li>"; break; case ValidationSummaryDisplayMode.List result += v.ErrorMessage; result += "<br/>"; break; case ValidationSummaryDisplayMode.SingleParagraph result += v.ErrorMessage; result += " "; break; } } } return result; } } } }