ValidatorCollection.GetEnumerator Method ()

 

Returns an IEnumerator instance for the ValidatorCollection collection.

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

public IEnumerator GetEnumerator()

Return Value

Type: System.Collections.IEnumerator

The IEnumerator for the collection.

Use this method to create an System.Collections.IEnumerator instance that can be iterated through easily to get each item in the ValidatorCollection collection.

The following code example demonstrates using the GetEnumerator method.

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

.NET Framework
Available since 1.1
Return to top
Show: