Showing posts with label dopostback. Show all posts
Showing posts with label dopostback. Show all posts

Monday, March 23, 2009

HOW TO: override __doPostBack function

hi,
this function let u override the doPostBack function
it is ueful when u want to make some action before submit

THE FUNCTION CODE:

var __oldDoPostBack = __doPostBack; // replace __doPostBack with another function
__doPostBack = AlwaysFireBeforeFormSubmit;
function AlwaysFireBeforeFormSubmit (eventTarget, eventArgument)
{
var question = "";
if(eventTarget == "btn_save")
{ // if save was pushed-there is nothing to confirm
__oldDoPostBack (eventTarget, eventArgument);
return;
}
if(statusWasChanged == "false")
{ // if nothing was changed-there is nothing to confirm
__oldDoPostBack (eventTarget, eventArgument);
return;
} else if(confirm("Discard your changes?"))
__oldDoPostBack (eventTarget, eventArgument);
}