TCustomValidator performs user-defined validation (either server-side or client-side or both) on an input component.
To create a server-side validation function, provide a handler for the OnServerValidate event that performs the validation. The data string of the input component to validate can be accessed by the value property of the event parameter which is of type TServerValidateEventParameter. The result of the validation should be stored in the isValid property of the event parameter.
To create a client-side validation function, add the client-side validation javascript function to the page template. The function should have the following signature:
<script type="text/javascript"><!--
function ValidationFunctionName(sender, parameter)
{
// if(parameter == ...)
// return true;
// else
// return false;
}
--></script>
Use the ClientValidationFunction property to specify the name of the client-side validation script function associated with the TCustomValidator.
Namespace: System.Web.UI.WebControls
Properties
ClientValidationFunction, string, kept in viewstate
Gets or sets the name of the custom client-side script function used for validation.
Events
OnServerValidate Occurs when validation is performed on the server.
Event delegates must set the event parameter TServerValidateEventParameter.isValid
to false if they find the value is invalid.
Set the anchor ID for the error message link. If the value is "true" then the ID of the ControlToValidate will be used otherwise the given value will be used as the anchor.
This method is invoked when the server side validation happens.
It will raise the OnServerValidate event. The method also allows derived classes to handle the event without attaching a delegate. Note The derived classes should call parent implementation to ensure the OnServerValidate event is raised.