Export (0) Print
Expand All
0 out of 3 rated this helpful - Rate this topic

ValidatorCollection Class

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

Namespace: System.Web.UI
Assembly: System.Web (in system.web.dll)
public sealed class ValidatorCollection : ICollection, IEnumerable
public final class ValidatorCollection implements ICollection, IEnumerable
public final class ValidatorCollection implements ICollection, IEnumerable
Not applicable.

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.
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;

// Get 'Validators' of the page to myCollection.
ValidatorCollection myCollection = get_Validators();

// Get the Enumerator.
IEnumerator myEnumerator = myCollection.GetEnumerator();
// Print the values in the ValidatorCollection.
String myStr = " ";
while (myEnumerator.MoveNext()) {
    myStr += System.Convert.ToString(myEnumerator.get_Current());
    myStr += " ";
}
messageLabel.set_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 98, Windows Server 2000 SP4, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.

.NET Framework

Supported in: 3.0, 2.0, 1.1, 1.0
Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

ADD
Show:
© 2014 Microsoft. All rights reserved.