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

N

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.
 
N

northof40

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.
 
N

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,768
Messages
2,569,574
Members
45,051
Latest member
CarleyMcCr

Latest Threads

Top