Please help: Validating input from a combination of controls

Discussion in 'ASP .Net' started by Paul, Nov 26, 2003.

  1. Paul

    Paul Guest

    Hi,

    I'm developing a search facility for my web app. In order for the
    search criteria to be valid the user must (a) enter some text in a
    text box and check and least one checkbox (of which there are two)
    and/or (b) select at least one item from a multiple select list box.
    I've written the javascript to do the client side validation which
    gets called on the click event of my search button. I'd like to
    implement server side validation using the validation controls but am
    not sure how to achieve this. Can the custom validation control be
    used in this instance (i.e. to validate the input from multiple
    controls). If so how?

    Thanks,

    Paul
    Paul, Nov 26, 2003
    #1
    1. Advertising

  2. Paul

    Peter Blum Guest

    Yes, a CustomValidator can be built to describe the same logic on the server
    side as on the client side. The trick is to avoid having it valid except
    when this particular button is pressed. In this case, I'd avoid using the
    Page.Validate() method which is automically called when the submit button's
    CausesValidation = true. Instead, I'd hook up that button's Click event
    handler and have it call Validate() on the CustomValidator. Set the button's
    CausesValidation to false. If CustomValidator.IsValid is false, regenerate
    the page without saving data.

    This scenerio is a very common one that requires something called
    "Validation Groups". ASP.NET 2.0 (Whidbey) will eventually have this
    feature. In the meantime, I offer a commercial product that supports
    Validation Groups and building the extensive logical case you describe
    without coding. In fact, with my validators, it will generate the correct
    JavaScript for you and it will work on IE, IE/Mac, Netscape 6+, Mozilla,
    Opera 7 and Safari (whereas Microsoft's client-side validation is IE
    specific.) My product is "Professional Validation And More". Learn more at
    http://www.peterblum.com/vam/home.aspx.

    --- Peter Blum
    www.PeterBlum.com
    Email:

    "Paul" <> wrote in message
    news:...
    > Hi,
    >
    > I'm developing a search facility for my web app. In order for the
    > search criteria to be valid the user must (a) enter some text in a
    > text box and check and least one checkbox (of which there are two)
    > and/or (b) select at least one item from a multiple select list box.
    > I've written the javascript to do the client side validation which
    > gets called on the click event of my search button. I'd like to
    > implement server side validation using the validation controls but am
    > not sure how to achieve this. Can the custom validation control be
    > used in this instance (i.e. to validate the input from multiple
    > controls). If so how?
    >
    > Thanks,
    >
    > Paul
    Peter Blum, Nov 29, 2003
    #2
    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. Thierry

    validating input from the form

    Thierry, Nov 10, 2003, in forum: ASP .Net
    Replies:
    1
    Views:
    300
    William F. Robertson, Jr.
    Nov 10, 2003
  2. Thierry
    Replies:
    1
    Views:
    1,268
    S. Justin Gengo
    Nov 11, 2003
  3. darrel
    Replies:
    1
    Views:
    457
    darrel
    Jun 24, 2004
  4. Peter Morris [Air Software Ltd]

    Validating user HTML input

    Peter Morris [Air Software Ltd], Jan 2, 2005, in forum: ASP .Net
    Replies:
    5
    Views:
    506
    Peter Morris [Air Software Ltd]
    Jan 9, 2005
  5. KK
    Replies:
    2
    Views:
    546
    Big Brian
    Oct 14, 2003
Loading...

Share This Page