I am using ASP.Net web forms. My goal is to ask a user a question when leaving the page. I tried using window.onbeforeunload for this. But in onbeforeunload the popup cannot be customized. I want to use my own popup too. The popup I created opens successfully. But after the popup is opened, the page closes immediately. Note: I'm trying to do it with Javascript. How do I resolve this situation?
var unSavedStatus = false;
window.onbeforeunload = SaveControl;
function SaveControl()
{
if(unSavedStatus)
myPopup.Show();
}