ValidatorCollection.Remove(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.
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)
Parameters
- validator
- IValidator
The validation server control to remove from the collection.
Examples
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
Applies to
See also
Colaborar conosco no GitHub
A fonte deste conteúdo pode ser encontrada no GitHub, onde você também pode criar e revisar problemas e solicitações de pull. Para obter mais informações, confira o nosso guia para colaboradores.