Adam

Adam

  • NA
  • 5
  • 0

Problem upon cancelling a postback with javascript's confirm()

Apr 26 2010 6:41 AM

I have an aspx page that interacts with a database. The user input gets stored into a session so that I can compare it to the database's current (concurrency) state. If the user moves to a different page, after applying the changes to the session, but before saving the data to the database. A javascript confirm() dialog pops up and warns the user that their session data will be lost if they continue. If the user cllicks cancel ( cancelling the postback) the user remains at the current page, as expected. However the next time any kind of postback is requested by the user, the old postback resumes, pushing the user to previously request page.
My page is quite complex,  I have a top panel for navigation purposes. I then have a tree view on the left of the page for sub navigation and a Multiview to the right which displays different usercontrol pages depending on which option is currently selected within the treeview. When ever a tree view option is selected the usercontrol changes and the session data persists. If a navigation option from the top panel is requested, the dialog warns the user that leaving the page will destroy any unsaved session data. If the user cancels the operation the postback is cancelled. however, if the user next clicks on one of the treeview navigation options, the previous postback (top panel button) is performed, which means the session data is destroyed and the user is sent to the wrong page.
So basically the javascript  return confirm() dialog seems to only halt the current postback, until the next postback is requested. It seems that the old postback is remembered and given priority over a new postback. Can this behaviour be stopped so that the newer and correct postback is executed.
Any help is appreciated, this is my first post so  I hope it makes sense.
 
 

Answers (2)