ValidatorCollection Class
Exposes an array of IValidator references. This class cannot be inherited.
For a list of all members of this type, see ValidatorCollection Members.
System.Object
System.Web.UI.ValidatorCollection
[Visual Basic] NotInheritable Public Class ValidatorCollection Implements ICollection, IEnumerable [C#] public sealed class ValidatorCollection : ICollection, IEnumerable [C++] public __gc __sealed class ValidatorCollection : public ICollection, IEnumerable [JScript] public class ValidatorCollection implements ICollection, IEnumerable
Thread Safety
Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.
Remarks
Each IValidator reference is associated with a validation server control contained on the requested page. These controls add themselves to this collection when the Init method of the Page is called. They remove themselves when the Unload method of the Page is called. The Page class inherits both of these methods from the Control class.
You can access this collection, its methods, and its properties through the Page.Validators property. If the tested condition of any validator in this collection fails, the Page.IsValid property is set to false.
Example
[Visual Basic, C#] The following sample demonstrates using the constructor and GetEnumerator method of the ValidatorCollection.
[Visual Basic] ' Get 'Validators' of the page to myCollection. Dim myCollection As ValidatorCollection = Page.Validators ' Get the Enumerator. Dim myEnumerator As IEnumerator = myCollection.GetEnumerator() ' Print the values in the ValidatorCollection. Dim myStr As String = " " While myEnumerator.MoveNext() myStr += myEnumerator.Current.ToString() myStr += " " End While messageLabel.Text = myStr [C#] // Get 'Validators' of the page to myCollection. ValidatorCollection myCollection = Page.Validators; // Get the Enumerator. IEnumerator myEnumerator = myCollection.GetEnumerator(); // Print the values in the ValidatorCollection. string myStr = " "; while ( myEnumerator.MoveNext() ) { myStr += myEnumerator.Current.ToString(); myStr += " "; } messageLabel.Text = myStr;
[Visual Basic, C#]
[C++, JScript] No example is available for C++ or JScript. To view a Visual Basic or C# example, click the Language Filter button
in the upper-left corner of the page.
Requirements
Namespace: System.Web.UI
Platforms: Windows 2000, Windows XP Professional, Windows Server 2003 family
Assembly: System.Web (in System.Web.dll)
See Also
ValidatorCollection Members | System.Web.UI Namespace | IValidator | Page.Validators