Firing server object/web service from a client validation...

Discussion in 'ASP .Net' started by arc, Feb 5, 2004.

  1. arc

    arc Guest

    I have a server object that performs zipcode validation based on zipcode
    entered in the web form.
    Ideally this should work as follows:
    Once the zip code is entered in the edit box it should validate the
    entry with this server object before moving to enter state in the next
    dropdown field.

    - What is the event by which we can do this for the edit box? (OnBlur doesnt
    seem to capture the text though it fires up the server object)
    - This works fine when the validation is performed at the server level but
    user has to wait until the submit button is pressed, this is not feasible
    here.

    Thanks Much,
    Arc
     
    arc, Feb 5, 2004
    #1
    1. Advertising

  2. If you write client-side javascript, you can trap the OnChange event of the
    <input type="text" /> that you want to validate, and then either do your own
    custom validation, or else call the ASP.NET validation system. I have always
    called the ASP.NET validators as a whole, and not individually, so you would
    have to poke through the script to see if you can get at this individually
    or if you need to call validation on everything (which may cause problems if
    you have required field validators that you haven't get gotten to on the
    page). What I typically do is client-side validation where I present all of
    the problems at the end, and then present very descriptive error messages
    that point them to the control that is incorrect, rather than checking as
    they type. If you wanted to get super-fast responses, you could trap
    onkeydown and check after every keystroke, but that seems like overkill to
    me.

    --
    Chris Jackson
    Software Engineer
    Microsoft MVP - Windows Client
    Windows XP Associate Expert
    --
    More people read the newsgroups than read my email.
    Reply to the newsgroup for a faster response.
    (Control-G using Outlook Express)
    --

    "arc" <> wrote in message
    news:...
    >I have a server object that performs zipcode validation based on zipcode
    > entered in the web form.
    > Ideally this should work as follows:
    > Once the zip code is entered in the edit box it should validate the
    > entry with this server object before moving to enter state in the next
    > dropdown field.
    >
    > - What is the event by which we can do this for the edit box? (OnBlur
    > doesnt
    > seem to capture the text though it fires up the server object)
    > - This works fine when the validation is performed at the server level but
    > user has to wait until the submit button is pressed, this is not feasible
    > here.
    >
    > Thanks Much,
    > Arc
    >
    >
     
    Chris Jackson, Feb 6, 2004
    #2
    1. Advertising

  3. arc

    Peter Blum Guest

    First, I notice that you cross posted. Please don't do that as we cannot
    follow all the responses elsewhere and may be wasting our time replying when
    you already have a satisfactory response from another newsgroup.

    You can write a CustomValidator to do this work. Internally the
    customvalidator (and all validators) hook up to the onchange event of a
    textbox. If you intend to maintain this validation on the client-side, it
    may be very inefficient as you would have to provide a javascript
    representation of all zip codes. That could make for a huge page. In this
    case, I would recommend posting back to the server to do the work. Another
    suggestion is to simply validate the pattern is ##### or #####-####. You can
    use a RegularExpressionValidator to do this. Microsoft has even supplied a
    regular expression for you in the property editor for the Expression
    property.

    --- Peter Blum
    www.PeterBlum.com
    Email:
    Creator of "Professional Validation And More" at
    http://www.peterblum.com/vam/home.aspx

    "arc" <> wrote in message
    news:...
    > I have a server object that performs zipcode validation based on zipcode
    > entered in the web form.
    > Ideally this should work as follows:
    > Once the zip code is entered in the edit box it should validate the
    > entry with this server object before moving to enter state in the next
    > dropdown field.
    >
    > - What is the event by which we can do this for the edit box? (OnBlur

    doesnt
    > seem to capture the text though it fires up the server object)
    > - This works fine when the validation is performed at the server level but
    > user has to wait until the submit button is pressed, this is not feasible
    > here.
    >
    > Thanks Much,
    > Arc
    >
    >
     
    Peter Blum, Feb 6, 2004
    #3
  4. arc

    Steve Fulton Guest

    Peter Blum wrote:
    > First, I notice that you cross posted. Please don't do that as we cannot
    > follow all the responses elsewhere and may be wasting our time replying when
    > you already have a satisfactory response from another newsgroup.


    That is not a problem with cross-posting. Replies in any group will be
    propagated to all groups. Multi-posting (identical, *separate* posts to
    different newsgroups) suffers from this problem and is a strict no-no.
    Cross-posting to an excessive number of unrelated groups is frowned upon.

    --
    Steve

    Common sense is the collection of prejudices acquired by age eighteen.
    -Albert Einstein
     
    Steve Fulton, Feb 6, 2004
    #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. Matt
    Replies:
    14
    Views:
    4,166
    Chad Z. Hower aka Kudzu
    Jan 30, 2004
  2. John Dalberg

    Client validation not firing

    John Dalberg, Mar 1, 2005, in forum: ASP .Net
    Replies:
    8
    Views:
    5,823
    John Dalberg
    Mar 1, 2005
  3. =?Utf-8?B?dmlkeWE=?=
    Replies:
    1
    Views:
    770
    Kevin Spencer
    Jun 2, 2005
  4. arc
    Replies:
    2
    Views:
    149
    Steve Fulton
    Feb 6, 2004
  5. Replies:
    0
    Views:
    223
Loading...

Share This Page