Leaving page event
Hi all, I'm currently trying to create a page with the user will be able to create an order form. I would like to add in some codes to generate a message box when the user navigates away from that page. I tried using both "Protected Override Void onUnLoad(EventArgs e)" as well as "void Page_Unload" but both methods seems to execute right after Page_Load, which resulted in the displaying of the message box the moment the page loads. Appreciate if anyone can advise me on this

Yi Rong TanPosted Jan 14, 2015, 8:28 PM
Bhushan GawalePosted Jan 12, 2015, 2:13 AM
In that case - you will need to take some extra efforts and need to add logic in the event which will differentiate refresh and redirect calls, something like this
http://www.anandkanatt.com/how-do-i-detect-browser-window-closed-refreshed/
Yi Rong TanPosted Jan 12, 2015, 1:31 AM
Bhushan GawalePosted Jan 12, 2015, 12:53 AM
Try using onbeforeunload event
http://www.w3schools.com/tags/ev_onbeforeunload.asp