ValidatorCollection.Add(IValidator) Method
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
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
意見反應
https://aka.ms/ContentUserFeedback。
即將登場:在 2024 年,我們將逐步淘汰 GitHub 問題作為內容的意見反應機制,並將它取代為新的意見反應系統。 如需詳細資訊,請參閱:提交並檢視相關的意見反應