?
Solved

Looking for Javascript to prevent AJAX postback

Posted on 2008-10-28
2
Medium Priority
?
686 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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

jQuery is a JavaScript library that greatly simplifies JavaScript programming. AJAX is an acronym formed from "Asynchronous JavaScript and XML."  AJAX refers to any communication between client and server, when the human client does not observe a…
Introduction HyperText Transfer Protocol (http://www.ietf.org/rfc/rfc2616.txt) or "HTTP" is the underpinning of internet communication.  As a teacher of web development I have heard many questions, mostly from my younger students who have come to t…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …
Suggested Courses
Course of the Month12 days, 13 hours left to enroll

777 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