ValidatorCollection.Remove(IValidator) ValidatorCollection.Remove(IValidator) ValidatorCollection.Remove(IValidator) ValidatorCollection.Remove(IValidator) Method

Определение

Удаляет указанный проверочный серверный элемент управления из коллекции ValidatorCollection.Removes the specified validation server control from the page's ValidatorCollection collection.

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

Параметры

validator
IValidator IValidator IValidator IValidator

Проверяющий серверный элемент управления, удаляемый из коллекции.The validation server control to remove from the collection.

Примеры

В следующем примере кода показано, как использовать метод Remove.The following code example demonstrates how to use the Remove method.

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


// Remove the RequiredFieldValidator.
if(Validators.Contains(myRequiredFieldValidator))
{
   this.Validators.Remove(myRequiredFieldValidator);
   Response.Write("RequiredFieldValidator is removed from ValidatorCollection<br>");
   Response.Write("ValidatorCollection count after removing the Validator: "+Validators.Count+"<br>");
}
else
{
   Response.Write("ValidatorCollection does not contain RequiredFieldValidator");
}
 Controls.Add(myForm)
 myForm.Controls.Add(myLabel1)
 myForm.Controls.Add(myTextBox)
 myForm.Controls.Add(myButton)
 Me.Validators.Add(myRequiredFieldValidator)
 myForm.Controls.Add(myLabel)

' Remove the RequiredFieldValidator.
 If Validators.Contains(myRequiredFieldValidator) Then
    Me.Validators.Remove(myRequiredFieldValidator)
    Response.Write("RequiredFieldValidator is removed from ValidatorCollection<br>")
    Response.Write("ValidatorCollection count after removing the Validator: " + Validators.Count.ToString() + "<br>")
 Else
    Response.Write("ValidatorCollection does not contain RequiredFieldValidator")
 End If

Применяется к

Дополнительно