Asp.net, c#, custom validator, AJAX, client validate script, wait for server response

Discussion in 'ASP .Net Web Controls' started by Jay Douglas, Feb 27, 2007.

  1. Jay Douglas

    Jay Douglas Guest

    Hello all,

    I'm in need of a custom validator that:

    1). Runs server side code using ajax through a client validate function
    2). Client validate function does not set args.IsValid until the server
    responds
    3). Any submit actions (via link button) do not take place until all client
    validate functions run.

    Pseudo client validate function (javascript):

    I would like a method that works like:
    function myClientValidate(sender, args)
    {
    // here's where i'd like the args to be sent
    args.IsValid = WebForm_DoCallback(.....).;
    }

    Unfortunately, the CallBack fires a different event to deal with the
    response, so I'm forced to do something like:

    var isControlValid = false; // dynamically set on page load

    function myClientValidate(sender, args)
    {
    return isControlValid;
    }

    function executeValidatorCallback()
    {
    WebForm_DoCallback(.....)
    }

    function updateCallbackResults(returnValue, context)
    {
    isControlValid = returnValue; // basically context just returns true or
    false
    }

    To keep isControlValid I'm running executeValidatorCallback() on certain
    page events and on a timed interval. This seems really messy to me.

    So my question is:
    How do I send a request to the server using javascript and wait for the
    server responds before the javascript continues.

    I'm at a loss, any advice would be great.

    Thanks,
    Jay
     
    Jay Douglas, Feb 27, 2007
    #1
    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. P McGinness
    Replies:
    0
    Views:
    297
    P McGinness
    Jan 14, 2004
  2. Jay Douglas
    Replies:
    0
    Views:
    527
    Jay Douglas
    Feb 27, 2007
  3. Andrew Jocelyn

    AJAX client script bug with validator

    Andrew Jocelyn, Feb 10, 2008, in forum: ASP .Net
    Replies:
    4
    Views:
    573
    Andrew Jocelyn
    Feb 11, 2008
  4. Lewis Holmes
    Replies:
    5
    Views:
    2,756
    Allen Chen [MSFT]
    Mar 18, 2009
  5. Rajat
    Replies:
    3
    Views:
    704
    Jorgen Grahn
    Jan 8, 2010
Loading...

Share This Page