Share via


Validate Method (Common)

Performs control validation, and then sets the IsValid property based on the results of the validation.

public virtual void Validate()

Inheritance

The following is a list of the classes that inherit the Validate method from the BaseValidator class.

CompareValidator RegularExpressionValidator
CustomValidator RequiredFieldValidator
RangeValidator  

Remarks

The Validate method causes the IsValid property of the control to be set to true or false, depending on the outcome of the validation test.

Example

The following example demonstrates how to use the Validate method to validate that the text entered by a user falls within the permitted range.

Sub OnCmdClick(sender As Object, e As EventArgs)
   RequiredFieldValidator1.Validate()
   If Page.IsValid Then
      ActiveForm = Form2
   End If
End Sub 

[C#]

void OnCmdClick(Object sender, EventArgs e)
{
   RequiredFieldValidator1.Validate();
   if (Page.IsValid)
     ActiveForm = Form2;
}  

See Also

Applies to: BaseValidator Class