Solved

Looking for Javascript to prevent AJAX postback

Posted on 2008-10-28
2
682 Views
Last Modified: 2010-08-05
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.
0
Comment
Question by:aiscom
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
2 Comments
 

Author Comment

by:aiscom
ID: 22832247
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?
0
 

Accepted Solution

by:
aiscom earned 0 total points
ID: 22833952
I was able to stop the postback by using information from the following site:

http://www.dotnetcurry.com/ShowArticle.aspx?ID=176&AspxAutoDetectCookieSupport=1

I used the event handler to check if changes had been made and if so cancel.

Yeah, I get 500 points for answering my own question.
0

Featured Post

Salesforce Made Easy to Use

On-screen guidance at the moment of need enables you & your employees to focus on the core, you can now boost your adoption rates swiftly and simply with one easy tool.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction This article shows how to use the open source plupload control to upload multiple images. The images are resized on the client side before uploading and the upload is done in chunks. Background I had to provide a way for user…
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
This video Micro Tutorial shows how to password-protect PDF files with free software. Many software products can do this, such as Adobe Acrobat (but not Adobe Reader), Nuance PaperPort, and Nuance Power PDF, but they are not free products. This vide…
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.

705 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question