tags:

views:

230

answers:

1

I've found posts about making a click event with jQuery for a button, however I need a little more then that.

When any postback occurs on a page, I need to fire off a jQuery click event. Based on a condition, I want to continue processing (including running the server-side event code after the jQuery code), or, perform a redirect.

I'm not quite sure how to go about this.

Your help is appreciated!

A: 

If you want to handle every postback, the simplest way to do it is to replace the __doPostBack function with your own wrapper, like this:

var originalDoPostBack = __doPostBack;
__doPostBack = function() { 
    //Run some code
    if(something)
        originalDoPostBack.apply(this, arguments);
}
SLaks
Thanks SLaks --If I use your sample -- and my condition "something" is the test I need to determine to do a redirect... And I leave that code as is and don't handle the 'else', will it automatically execute my server code, or do I need to return true(or something else)?
TheGeekYouNeed
Handle the form's submit event and cancel it. (Selectively)
SLaks