views:

362

answers:

2

Hi

The ServerValidate event of CustomValidator has 2 parameters: source and args.

What each of them point out to? Any description of them please.

Thank you

+1  A: 

Argument source is reference of validator control and args represent event specific data.

protected void CustomValidator1_ServerValidate(object source, ServerValidateEventArgs args)
{
    if (args.Value != "OK")
    {
        args.IsValid = false;
    }
}
adatapost
+3  A: 

Like all "EventHandler"-style events, source will refer to the object that raised the event (in this case the CustomValidator instance) and args will refer to event data associated to this specific event.

For ServerValidate event, the args parameter is of type ServerValidateEventArgs. It has two important properties:

  • Value: returns the value of the input control you're validating (e.g. text in the textbox.)
  • IsValid: you set this property to true if the validation is successful and false if it's not.
Mehrdad Afshari