By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
432,483 Members | 1,039 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 432,483 IT Pros & Developers. It's quick & easy.

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

P: n/a
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
Feb 27 '07 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.