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

Discussion in 'ASP .Net Web Controls' started by northof40, Oct 26, 2007.

  1. northof40

    northof40 Guest

    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.
    northof40, Oct 26, 2007
    #1
    1. Advertising

  2. Try using the sender parameter
    --
    Nathan Sokalski

    http://www.nathansokalski.com/

    "northof40" <> wrote in message
    news:...
    > 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.
    >
    Nathan Sokalski, Oct 29, 2007
    #2
    1. Advertising

  3. northof40

    northof40 Guest

    On Oct 30, 9:47 am, "Nathan Sokalski" <> 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
    > ://www.nathansokalski.com/
    >
    > "northof40" <> wrote in message
    >
    > news:...
    >
    > > 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.
    northof40, Nov 1, 2007
    #3
  4. 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

    http://www.nathansokalski.com/

    "northof40" <> wrote in message
    news:...
    > On Oct 30, 9:47 am, "Nathan Sokalski" <> 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
    >> ://www.nathansokalski.com/
    >>
    >> "northof40" <> wrote in message
    >>
    >> news:...
    >>
    >> > 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.

    >
    >
    Nathan Sokalski, Nov 2, 2007
    #4
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. jm
    Replies:
    3
    Views:
    4,734
    Greg Burns
    Oct 16, 2003
  2. Mike P

    OnServerValidate

    Mike P, Oct 23, 2003, in forum: ASP .Net
    Replies:
    3
    Views:
    833
    Mike P
    Oct 23, 2003
  3. Rigs
    Replies:
    0
    Views:
    374
  4. Rigs
    Replies:
    10
    Views:
    8,379
    Laurent Bugnion
    Nov 17, 2006
  5. Replies:
    0
    Views:
    1,355
Loading...

Share This Page