Imports System Imports System.Web.UI Imports System.Web.UI.WebControls Namespace Juranek.Web.Controls '/ <summary> '/ This control inheirits the ASP.NET ValidationSummary control but adds '/ the ability to dynamically add error messages without requiring '/ validation controls. '/ </summary> '/ <author>Scott Juranek</author> '/ <remarks>3/4/2002: Original Implementation</remarks> Public Class ValidationSummary Inherits System.Web.UI.WebControls.ValidationSummary '/ <summary> '/ Allows the caller to place custom text messages inside the validation '/ summary control '/ </summary> '/ <param name="msg">The message you want to appear in the summary</param> Public Sub AddErrorMessage(msg As String) Me.Page.Validators.Add(New DummyValidator(msg)) End Sub 'AddErrorMessage End Class 'ValidationSummary '/ <summary> '/ The validation summary control works by iterating over the Page.Validators '/ collection and displaying the ErrorMessage property of each validator '/ that return false for the IsValid() property. This class will act '/ like all the other validators except it always is invalid and thus the ErrorMessage '/ property will always be displayed. '/ </summary> '/ <author>Scott Juranek</author> '/ <remarks>3/4/2002: Original Implementation</remarks> Friend Class DummyValidator Implements IValidator Private errorMsg As String Public Sub New(msg As String) errorMsg = msg End Sub 'New Public Property ErrorMessage() As String Get Return errorMsg End Get Set errorMsg = value End Set End Property Public Property IsValid() As Boolean Get Return False End Get Set End Set End Property Public Sub Validate() End Sub 'Validate End Class 'DummyValidator End Namespace 'Juranek.Web.Controls>this should be useful for everyone. it is a subclass of the validationsummary control that allows u to add your own error messages. this means the validation control doesn't have to have another validation control on the web form. i need a little help converting it to vb and how to implement it on the web form. Any takers. Thanks.
>using System; >using System.Web.UI; >using System.Web.UI.WebControls; > >namespace Juranek.Web.Controls >{ > /// <summary> > /// This control inheirits the ASP.NET ValidationSummary control but adds > /// the ability to dynamically add error messages without requiring > /// validation controls. > /// </summary> > /// <author>Scott Juranek</author> > /// <remarks>3/4/2002: Original Implementation</remarks> > public class ValidationSummary : System.Web.UI.WebControls.ValidationSummary > { > /// <summary> > /// Allows the caller to place custom text messages inside the validation > /// summary control > /// </summary> > /// <param name="msg">The message you want to appear in the summary</param> > public void AddErrorMessage(string msg) { > this.Page.Validators.Add(new DummyValidator(msg)); > } > } > > /// <summary> > /// The validation summary control works by iterating over the Page.Validators > /// collection and displaying the ErrorMessage property of each validator > /// that return false for the IsValid() property. This class will act > /// like all the other validators except it always is invalid and thus the ErrorMessage > /// property will always be displayed. > /// </summary> > /// <author>Scott Juranek</author> > /// <remarks>3/4/2002: Original Implementation</remarks> > internal class DummyValidator : IValidator { > > private string errorMsg; > > public DummyValidator(string msg) { > errorMsg = msg; > } > > public string ErrorMessage{ > get{ return errorMsg;} > set{ errorMsg = value;} > } > > public bool IsValid{ > get{return false;} > set{} > } > > public void Validate() { > } > } >} > >