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

J

Jay Douglas

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,581
Members
45,056
Latest member
GlycogenSupporthealth

Latest Threads

Top