views:

45

answers:

4

Using ASP.Net, VB.Net

When i close or exit the page, it should show the pop up message like "page closing"

Need code help

A: 
<body onunload="event.returnValue = 'Check?';">

That's also pretty much the code that's used if you start typing an answer here and try to close or navigate away. ;-)

Here's an answer at another forum as well. http://www.hotscripts.com/forums/javascript/16890-code-showing-you-sure-you-want-navigate-away-page.html

David Stratton
A: 

try this:

<script language="JavaScript">
        window.onbeforeunload = confirmExit;
        function confirmExit() {
            return "You want to leave this page?";
        }
    </script>
anishmarokey
I don't think that will work if the user clicks on the x or tries to navigate away. That sample just shows how to show a confirmation dialog on a button click. The button in the example is a standard html button, not the browser's close button.
David Stratton
A: 

You can also use jQuery popup message at the time of page closing

$(window).bind("beforeunload", function() { return inFormOrLink || confirm("Do you really want to close?"); })

Nitesh Katare
A: 

Here is the link which can show you the sample code to show the message when the page is closed/Exited.

http://usefulscripts.wordpress.com/2007/10/16/window-onbeforeunload-javascript-code/

You can also further call the serverside methods using ajax in Javascript functions. The examples are present on the following linkS: http://www.singingeels.com/Articles/Using_Page_Methods_in_ASPNET_AJAX.aspx http://www.dotnetcurry.com/ShowArticle.aspx?ID=109&amp;AspxAutoDetectCookieSupport=1

Shivkant