Home All Groups Group Topic Archive Search About

OnServerValidate handler - how to know which CustomValidator is using it ?

Author
26 Oct 2007 7:01 AM
northof40
Hi - I have set up a number of CustomValidators all of which specify
the same method as on their 'OnServerValidate' property.

Within the method handling the custom validation how can I determine
which CustomValidator is calling ?

I would like to modify the error message dynamically but without
knowing whihc CustomValidator is firing I cannot.

Any ideas ?

Richard.

Author
29 Oct 2007 8:47 PM
Nathan Sokalski
Try using the sender parameter
--
Nathan Sokalski
njsokal***@hotmail.com
http://www.nathansokalski.com/

Show quoteHide quote
"northof40" <shearich***@gmail.com> wrote in message
news:1193382105.477436.81820@q3g2000prf.googlegroups.com...
> Hi - I have set up a number of CustomValidators all of which specify
> the same method as on their 'OnServerValidate' property.
>
> Within the method handling the custom validation how can I determine
> which CustomValidator is calling ?
>
> I would like to modify the error message dynamically but without
> knowing whihc CustomValidator is firing I cannot.
>
> Any ideas ?
>
> Richard.
>
Author
1 Nov 2007 1:39 AM
northof40
On Oct 30, 9:47 am, "Nathan Sokalski" <njsokal***@hotmail.com> wrote:
Thanks for your reply - I'm not quite sure what you mean though.

When I look at source.ToString() I get ...

"System.Web.UI.WebControls.CustomValidator"

.... which doesn't tell me which CustomValidator is causing the handler
to fire. Maybe I misunderstood what you meant - could you expand on
it ?

Thanks

Richard.



Show quoteHide quote
> Try using the sender parameter
> --
> Nathan Sokalski
> njsokal...@hotmail.comhttp://www.nathansokalski.com/
>
> "northof40" <shearich***@gmail.com> wrote in message
>
> news:1193382105.477436.81820@q3g2000prf.googlegroups.com...
>
> > Hi - I have set up a number of CustomValidators all of which specify
> > the same method as on their 'OnServerValidate' property.
>
> > Within the method handling the custom validation how can I determine
> > which CustomValidator is calling ?
>
> > I would like to modify the error message dynamically but without
> > knowing whihc CustomValidator is firing I cannot.
>
> > Any ideas ?
>
> > Richard.
Author
2 Nov 2007 3:46 AM
Nathan Sokalski
Try casting source as a CustomValidator, and then getting the ID attribute,
like the following (the following is VB.NET code):

CType(source,System.Web.UI.WebControls.CustomValidator).ID

Because source is an Object, you must first convert it to the correct type.
Then use the ID property to determine which of the validators it is. If this
does not work, it may help if you could send us your code so that we can see
exactly what techniques you are using.
--
Nathan Sokalski
njsokal***@hotmail.com
http://www.nathansokalski.com/

Show quoteHide quote
"northof40" <shearich***@gmail.com> wrote in message
news:1193881163.973946.10980@k35g2000prh.googlegroups.com...
> On Oct 30, 9:47 am, "Nathan Sokalski" <njsokal***@hotmail.com> wrote:
> Thanks for your reply - I'm not quite sure what you mean though.
>
> When I look at source.ToString() I get ...
>
> "System.Web.UI.WebControls.CustomValidator"
>
> ... which doesn't tell me which CustomValidator is causing the handler
> to fire. Maybe I misunderstood what you meant - could you expand on
> it ?
>
> Thanks
>
> Richard.
>
>
>
>> Try using the sender parameter
>> --
>> Nathan Sokalski
>> njsokal...@hotmail.comhttp://www.nathansokalski.com/
>>
>> "northof40" <shearich***@gmail.com> wrote in message
>>
>> news:1193382105.477436.81820@q3g2000prf.googlegroups.com...
>>
>> > Hi - I have set up a number of CustomValidators all of which specify
>> > the same method as on their 'OnServerValidate' property.
>>
>> > Within the method handling the custom validation how can I determine
>> > which CustomValidator is calling ?
>>
>> > I would like to modify the error message dynamically but without
>> > knowing whihc CustomValidator is firing I cannot.
>>
>> > Any ideas ?
>>
>> > Richard.
>
>