ValidatorCollection.Add Method (IValidator)

 

Adds the specified validation server control to the ValidatorCollection collection.

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

public void Add(
	IValidator validator
)

Parameters

validator
Type: System.Web.UI.IValidator

The validation server control to add.

When added to the ValidatorCollection collection of a Page object through the Validators property, the IValidator implementation takes part in validation. Its Validate method is called together with the Validate methods of all other validators. All validators then share in determining whether the Page object as a whole is valid.

The following code example demonstrates how to use the Add method.

Controls.Add(myForm);
myForm.Controls.Add(myLabel1);
myForm.Controls.Add(myTextBox);
myForm.Controls.Add(myButton);
this.Validators.Add(myRequiredFieldValidator);
myForm.Controls.Add(myLabel);
myForm.Controls.Add(myRequiredFieldValidator);

.NET Framework
Available since 1.1
Return to top
Show: