Sharing a Validator

Discussion in 'ASP .Net Web Controls' started by Nathan Sokalski, Nov 2, 2007.

  1. I have a form that contains a number of fields, all of which have
    validators. There are two submit buttons, one to update a record and one to
    add a record. Because the only difference in validation is to make sure
    someone is not using a username that is already in use, I would like to be
    able to use all the other validators for both the add and update buttons.
    However, because as far as I know a validator can only be in one
    validationgroup, that does not help me (although if they haven't already, I
    think it would be a great improvement for the next version of the .NET
    framework). Does anybody have any suggestions on a good way to solve my
    problem (having 2 copies of each validator would work and be very simple,
    but I would hope for a more efficient way)? Thanks.
    --
    Nathan Sokalski

    http://www.nathansokalski.com/
    Nathan Sokalski, Nov 2, 2007
    #1
    1. Advertising

  2. Nathan Sokalski

    ace_away Guest

    Why not use only one button? Change the text of the button from "Add" to
    "Update" depending on the data that is populating your form.

    Use a hidden textbox to keep the ID of the item. So if the textbox has a ID
    >0 then it's an update, else it's an Add.


    It's a little more complex than that, but it might get you started.



    "Nathan Sokalski" <> wrote in message
    news:...
    >I have a form that contains a number of fields, all of which have
    >validators. There are two submit buttons, one to update a record and one to
    >add a record. Because the only difference in validation is to make sure
    >someone is not using a username that is already in use, I would like to be
    >able to use all the other validators for both the add and update buttons.
    >However, because as far as I know a validator can only be in one
    >validationgroup, that does not help me (although if they haven't already, I
    >think it would be a great improvement for the next version of the .NET
    >framework). Does anybody have any suggestions on a good way to solve my
    >problem (having 2 copies of each validator would work and be very simple,
    >but I would hope for a more efficient way)? Thanks.
    > --
    > Nathan Sokalski
    >
    > http://www.nathansokalski.com/
    >
    ace_away, Nov 5, 2007
    #2
    1. Advertising

  3. I would do that, but unfortunately the client wants to always see both the
    Add and Update buttons. If I were designing what the page should look like,
    I would probably do something similar to your suggestion. But unfortunately,
    an unhappy client means an unhappy boss which means an unhappy paycheck. I
    guess that's all part of the business, with people caring so much about the
    look of the page.
    --
    Nathan Sokalski

    http://www.nathansokalski.com/

    "ace_away" <> wrote in message
    news:uSWs3h%...
    > Why not use only one button? Change the text of the button from "Add" to
    > "Update" depending on the data that is populating your form.
    >
    > Use a hidden textbox to keep the ID of the item. So if the textbox has a
    > ID
    > >0 then it's an update, else it's an Add.

    >
    > It's a little more complex than that, but it might get you started.
    >
    >
    >
    > "Nathan Sokalski" <> wrote in message
    > news:...
    >>I have a form that contains a number of fields, all of which have
    >>validators. There are two submit buttons, one to update a record and one
    >>to add a record. Because the only difference in validation is to make sure
    >>someone is not using a username that is already in use, I would like to be
    >>able to use all the other validators for both the add and update buttons.
    >>However, because as far as I know a validator can only be in one
    >>validationgroup, that does not help me (although if they haven't already,
    >>I think it would be a great improvement for the next version of the .NET
    >>framework). Does anybody have any suggestions on a good way to solve my
    >>problem (having 2 copies of each validator would work and be very simple,
    >>but I would hope for a more efficient way)? Thanks.
    >> --
    >> Nathan Sokalski
    >>
    >> http://www.nathansokalski.com/
    >>

    >
    >
    Nathan Sokalski, Nov 5, 2007
    #3
  4. Hi, Nathan

    The validators work regardless the button pressed, however, you can
    define the ValidationGroup for the button and that button would
    validate only with the specified validation group (or validators that
    does not have the ValidationGroup specified)... well, at least
    according to the docs -- I didn't make any test with it so far.

    Regards,

    Paulo Santos
    http://pjondevelopment.50webs.com

    On Nov 2, 6:38 pm, "Nathan Sokalski" <> wrote:
    > I have a form that contains a number of fields, all of which have
    > validators. There are two submit buttons, one to update a record and one to
    > add a record. Because the only difference in validation is to make sure
    > someone is not using a username that is already in use, I would like to be
    > able to use all the other validators for both the add and update buttons.
    > However, because as far as I know a validator can only be in one
    > validationgroup, that does not help me (although if they haven't already, I
    > think it would be a great improvement for the next version of the .NET
    > framework). Does anybody have any suggestions on a good way to solve my
    > problem (having 2 copies of each validator would work and be very simple,
    > but I would hope for a more efficient way)? Thanks.
    > --
    > Nathan Sokalski
    > ://www.nathansokalski.com/
    PJ on Development, Nov 8, 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. Jason
    Replies:
    1
    Views:
    716
  2. Dennis Gavrilov
    Replies:
    1
    Views:
    1,449
    Dennis Gavrilov
    Jul 24, 2003
  3. Leon Shaw

    sharing variables

    Leon Shaw, Jun 28, 2003, in forum: ASP .Net
    Replies:
    0
    Views:
    426
    Leon Shaw
    Jun 28, 2003
  4. Replies:
    4
    Views:
    893
    Richter~9.6
    Feb 13, 2007
  5. Nathan Sokalski

    Sharing a Validator

    Nathan Sokalski, Nov 2, 2007, in forum: ASP .Net
    Replies:
    8
    Views:
    290
    PJ on Development
    Nov 8, 2007
Loading...

Share This Page