ValidatorCollection.Remove(IValidator) Metodo

Definizione

Rimuove il controllo server di convalida specificato dall'insieme ValidatorCollection della pagina.

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)

Parametri

validator
IValidator

Controllo server di convalida da rimuovere dall'insieme.

Esempio

Nell'esempio di codice riportato di seguito viene illustrato come utilizzare il metodo Remove.

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

Si applica a

Vedi anche