how do I properly use onbeforeunload

hmstechsupport
hmstechsupport used Ask the Experts™
on
I'm building my web application and we want to use the javascript window.onbeforeunload event to prompt users to save changes to any edits they have made to data. So far, this works quite well, HOWEVER, it is very unpredictable when we are using callbacks. For example, we have a grid control and when the grid control is in edit mode we want to be able to use the onbeforeunload event to tell the user to update there edit before navigating away; this works well until the user clicks a button that causes a callback (the callback will not affect the grid editing).

So the question is, how do you use the onbeforeunload to tell the difference between a callback and a redirect/postback?
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Director, IT and Business Development
Commented:
This might help you:

http://aspnet.4guysfromrolla.com/articles/042005-1.aspx

Look at some of the sub articles it mentions and the section "Suppressing the Prompt for Button Web Controls".

Thanks.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial