ValidatorCollection Class

Definition

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

public ref class ValidatorCollection sealed : System::Collections::ICollection
public sealed class ValidatorCollection : System.Collections.ICollection
type ValidatorCollection = class
    interface ICollection
    interface IEnumerable
Public NotInheritable Class ValidatorCollection
Implements ICollection
Inheritance
ValidatorCollection
Implements

Examples

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

Remarks

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.

Constructors

ValidatorCollection()

Initializes a new instance of the ValidatorCollection class.

Properties

Count

Gets the number of references in the collection.

IsReadOnly

Gets a value that indicates whether the ValidatorCollection collection is read-only.

IsSynchronized

Gets a value that indicates whether the ValidatorCollection collection is synchronized.

Item[Int32]

Gets the validation server control at the specified index location in the ValidatorCollection collection.

SyncRoot

Gets an object that can be used to synchronize the ValidatorCollection collection.

Methods

Add(IValidator)

Adds the specified validation server control to the ValidatorCollection collection.

Contains(IValidator)

Determines whether the specified validation server control is contained within the page's ValidatorCollection collection.

CopyTo(Array, Int32)

Copies the validator collection to the specified array, beginning at the specified location.

Equals(Object)

Determines whether the specified object is equal to the current object.

(Inherited from Object)
GetEnumerator()

Returns an IEnumerator instance for the ValidatorCollection collection.

GetHashCode()

Serves as the default hash function.

(Inherited from Object)
GetType()

Gets the Type of the current instance.

(Inherited from Object)
MemberwiseClone()

Creates a shallow copy of the current Object.

(Inherited from Object)
Remove(IValidator)

Removes the specified validation server control from the page's ValidatorCollection collection.

ToString()

Returns a string that represents the current object.

(Inherited from Object)

Extension Methods

Cast<TResult>(IEnumerable)

Casts the elements of an IEnumerable to the specified type.

OfType<TResult>(IEnumerable)

Filters the elements of an IEnumerable based on a specified type.

AsParallel(IEnumerable)

Enables parallelization of a query.

AsQueryable(IEnumerable)

Converts an IEnumerable to an IQueryable.

Applies to

See also