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);
}

2 comments:

Anonymous said...

Add this code at the end of the page. so framework generated __doPostBack will be overridden.

__doPostBack()
{
alert('My Method');
}

Anonymous said...

Add this code at the end of the page. so framework generated __doPostBack will be overridden.

__doPostBack()
{
alert('My Method');
}

PRIYAN
http://www.priyans.com