Link to home
Start Free TrialLog in
Avatar of aiscom
aiscom

asked on

Looking for Javascript to prevent AJAX postback

I have an aspx page that has a few text fields and a custom control toolbar at the top. The toolbar has links like Save, Save and Close, Refresh and Back. When the page loads, I have a page variable called "ChangesMade" set to zero. When a user types into one of the text fields, I have a javascript function set the page variable "ChangesMade" equal to one. If the user clicks the "Back" button before saving, I check the "ChangesMade" variable and if necessary display a javascript confirm box to see if they want to save their changes. If they click that they do want to abort and have the option to save changes, I set Page_BlockSubmit = true; This works just fine and prevents thte page from posting back.

Now I have put all of this code into an AJAX update panel. When the user clicks Back, the function fires check the "ChangesMade" variable, sets the Page_BlockSubmit = true; BUT this does not prevent the postback. The page still goes to the server wich processes the "Back" command and the changes the user made are lost.

Does anyone know what javascript I need to prevent the AJAX postback from firing? Obviously Page_BlockSubmit = true; is not enough.
Avatar of aiscom
aiscom

ASKER

I know there must be some way to this. The AJAX toolkit provides a ConfirmButtonExtender control which confirms a button press and prevents the page from posting back if the person clicks cancel.

I lloked at the Javascript for this control in my debugger, but this is pretty advanced Javascript. Can anyone see how this control is preventing the AJAX postback?
ASKER CERTIFIED SOLUTION
Avatar of aiscom
aiscom

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial