Confirm Message before leaving ASP.NET Web Application

If you want to put up a confirm message to the user, so that he will be notified for any unsaved data. Check the following code snippet, which will alert the user, before close the browser/tab/moving to next page.

 <script language="JavaScript1.2" type="text/javascript">
        window.onbeforeunload = Unload_Call;

        function Unload_Call() {
            var Message = "Are you sure to leave this page?";
           return Message;

Copy the above code the page, where user needs to save information etc., The above code works in all latest browsers!

Happy Web Programming!


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s