ValidatorCollection ValidatorCollection ValidatorCollection 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
ValidatorCollectionValidatorCollectionValidatorCollectionValidatorCollection
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() ValidatorCollection() ValidatorCollection() ValidatorCollection()

Initializes a new instance of the ValidatorCollection class.

Properties

Count Count Count Count

Gets the number of references in the collection.

IsReadOnly IsReadOnly IsReadOnly IsReadOnly

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

IsSynchronized IsSynchronized IsSynchronized IsSynchronized

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

Item[Int32] Item[Int32] Item[Int32] Item[Int32]

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

SyncRoot SyncRoot SyncRoot SyncRoot

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

Methods

Add(IValidator) Add(IValidator) Add(IValidator) Add(IValidator)

Adds the specified validation server control to the ValidatorCollection collection.

Contains(IValidator) Contains(IValidator) Contains(IValidator) Contains(IValidator)

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

CopyTo(Array, Int32) CopyTo(Array, Int32) CopyTo(Array, Int32) CopyTo(Array, Int32)

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

Equals(Object) Equals(Object) Equals(Object) Equals(Object)

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

(Inherited from Object)
GetEnumerator() GetEnumerator() GetEnumerator() GetEnumerator()

Returns an IEnumerator instance for the ValidatorCollection collection.

GetHashCode() GetHashCode() GetHashCode() GetHashCode()

Serves as the default hash function.

(Inherited from Object)
GetType() GetType() GetType() GetType()

Gets the Type of the current instance.

(Inherited from Object)
MemberwiseClone() MemberwiseClone() MemberwiseClone() MemberwiseClone()

Creates a shallow copy of the current Object.

(Inherited from Object)
Remove(IValidator) Remove(IValidator) Remove(IValidator) Remove(IValidator)

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

ToString() ToString() ToString() ToString()

Returns a string that represents the current object.

(Inherited from Object)

Extension Methods

Cast<TResult>(IEnumerable) Cast<TResult>(IEnumerable) Cast<TResult>(IEnumerable) Cast<TResult>(IEnumerable)

Casts the elements of an IEnumerable to the specified type.

OfType<TResult>(IEnumerable) OfType<TResult>(IEnumerable) OfType<TResult>(IEnumerable) OfType<TResult>(IEnumerable)

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

AsParallel(IEnumerable) AsParallel(IEnumerable) AsParallel(IEnumerable) AsParallel(IEnumerable)

Enables parallelization of a query.

AsQueryable(IEnumerable) AsQueryable(IEnumerable) AsQueryable(IEnumerable) AsQueryable(IEnumerable)

Converts an IEnumerable to an IQueryable.

Applies to

See also