That definitely helps clear up the difference between client validation for
parameters have, it was a big help. However, in order to create the
status without returning a value from the evaluationfunction. Thanks.
"bruce barker" <brucebarker@discussions.microsoft.com> wrote in message
news:2AE048D9-A59E-4050-8691-702FFB65FC27@microsoft.com...
> the basevalidator has no builtin support for calling clientfunctions, you
> will need to write the hookup code yourself. client validation is pretty
> simple. validators are rendered as a span. then javascript code is
> rendered
> to create a javascript variable that references the span. then expando
> properties are added to this variable. your valiadation code would add
> additional properties via RegisterExpandoAttribute.
>
> there are 7 expando properties the base validator renders:
>
> enabled - bool used to enable/disable validation
> controltovalidate - the ClientId of the control to validate
> focusOnError - bool used to indicate set focus action
> errormessage - message to display if not valid
> display - display type
> isvalid - results of validation (set by the caller)
> validationGroup - the validation group
>
> if you want a client function called, your code needs to add the expando
> attribute:
>
> evaluationfunction - name of the client function to cal
>
> the evaluationfunction is called with one arg, the validator instance.
> your
> client code can then look at any expando attributes to decided what action
> to
> take. this fuction should return true/false for valid/not valid
>
> the CustomValidator will render the evaluationfunction based on the
> ClientValidationFunction server property. it will call the client function
> with two args
>
> clientFunction (val, args)
>
> where val is the validaor instance, and args is an object with two
> properties
>
> args.Value - the value of the control to validate
> args.IsValid - always initialized to true
>
> after the custom validator calls your client fucntion it returns
> args.IsValid to its caller (the standard validation code), and does not
> use
> your functions return value.
>
> one advantage of the custom validator (besides hooking the client
> function)
> is it has generic code to determine the value of the control to validate.
> if
> you use the base, you will need to write this code.
>
> pretty simple actually.
>
> -- bruce (sqlwork.com)
>
>
> "Nathan Sokalski" wrote:
>
>> I am trying to learn a little more about how to add client-side
>> validation
>> to custom validators that I write (by inheriting from the BaseValidator
>> class). I know that the name of the JavaScript function is assigned to an
>> attribute named 'evaluationfunction' and that the function returns true
>> or
>> false. However, some of the things I don't know or are unclear about are:
>>
>> 1. What parameters does the function assigned to evaluationfunction
>> receive?
>> If they are objects, what properties do they have?
>>
>> 2. On several of the websites I was looking at for help, they said the
>> function assigned to evaluationfunction had 2 parameters, but were
>> unclear
>> on what they were.
>>
>> 3. One of the validators (or actually types of validators) I am working
>> on
>> writing is validators that use client callbacks (also known as AJAX). I
>> know
>> how to implement the ICallbackEventHandler, but since the callback must
>> be
>> initiated by JavaScript, I am assuming the callback statement would be in
>> the function used for evaluationfunction. However, this would require
>> calling a function to apply the validation after returning from the
>> callback. From what I could get from the sites I could find, this would
>> involve calling the ValidatorUpdateDisplay function that exists in the
>> WebUIValidation.js file after returning. However, I was having a little
>> trouble figuring out what to pass it and where to get that value.
>>
>> If anybody could help me here, it would be greatly appreciated. Thanks.
>> --
>> Nathan Sokalski
>> njsokalski@hotmail.com
>>
http://www.nathansokalski.com/ >>
>>
>>