Szerkesztés

Megosztás a következőn keresztül:


ValidatorCollection.Add(IValidator) Method

Definition

Adds the specified validation server control to the ValidatorCollection collection.

public:
 void Add(System::Web::UI::IValidator ^ validator);
public void Add (System.Web.UI.IValidator validator);
member this.Add : System.Web.UI.IValidator -> unit
Public Sub Add (validator As IValidator)

Parameters

validator
IValidator

The validation server control to add.

Examples

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);
Controls.Add(myForm)
myForm.Controls.Add(myLabel1)
myForm.Controls.Add(myTextBox)
myForm.Controls.Add(myButton)
Me.Validators.Add(myRequiredFieldValidator)
myForm.Controls.Add(myLabel)
myForm.Controls.Add(myRequiredFieldValidator)

Remarks

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.

Applies to

See also