Export (0) Print
Expand All

ValidatorCollection Class

Exposes an array of IValidator references. This class cannot be inherited.

Namespace:  System.Web.UI
Assembly:  System.Web (in System.Web.dll)

'Declaration
<AspNetHostingPermissionAttribute(SecurityAction.LinkDemand, Level := AspNetHostingPermissionLevel.Minimal)> _
Public NotInheritable Class ValidatorCollection _
	Implements ICollection, IEnumerable
'Usage
Dim instance As ValidatorCollection

Each ValidatorCollection reference is associated with a validation server control contained on the requested page. These controls add themselves to this collection when the Init event of the Page object is handled. They remove themselves when the Unload event of the Page object is handled. 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.

The following code example demonstrates how to access the collection through the Page.Validators property and use the GetEnumerator method to iterate through the values.

' 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

System.Object
  System.Web.UI.ValidatorCollection

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

Windows 7, Windows Vista, Windows XP SP2, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP Starter Edition, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003, Windows Server 2000 SP4, Windows Millennium Edition, Windows 98

The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

.NET Framework

Supported in: 3.5, 3.0, 2.0, 1.1, 1.0

Community Additions

ADD
Show:
© 2014 Microsoft