Wrox Programmer Forums
Go Back   Wrox Programmer Forums > .NET > Other .NET > General .NET
|
General .NET For general discussion of MICROSOFT .NET topics that don't fall within any of the other .NET forum subcategories or .NET language forums.  If your question is specific to a language (C# or Visual Basic) or type of application (Windows Forms or ASP.Net) try an applicable forum category. ** PLEASE BE SPECIFIC WITH YOUR QUESTION ** When posting here, provide details regarding the Microsoft .NET language you are using and/or what type of application (Windows/Web Forms, etc) you are working in, if applicable to the question. This will help others answer the question without having to ask.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the General .NET section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old August 9th, 2004, 12:15 AM
Authorized User
 
Join Date: Feb 2004
Posts: 71
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to mahulda
Default Handling IE Close Event

Hi,

How Can I trap the event where the User Clicks the Close button
at the top-right corner of the Internet Explorer.

i.e I want to generate a message ("Do you Want to save your Data"). when the user clicks the close button.


-.. -..
__________________
-.. -..
 
Old August 9th, 2004, 02:48 AM
Friend of Wrox
 
Join Date: Jul 2004
Posts: 623
Thanks: 0
Thanked 1 Time in 1 Post
Default

write your code somewhere like Session_End or Dispose methode in your Global.asax file

--------------------------------------------
Mehdi.:)
 
Old August 9th, 2004, 08:47 AM
planoie's Avatar
Friend of Wrox
 
Join Date: Aug 2003
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
Default

The only way to do this is to utilize the <body> tag's onUnload attribute:

<body onUnload="confirm('Do you Want to save your Data?');">

However, you can't actually stop the window close from happening.

Furthermore, the "onUnload" event will fire on any event that causes the document to unload:
- Clicking a link
- Changing the address in the browser manuall
- Closing window
- Forward
- Back
 
Old August 9th, 2004, 09:21 AM
Authorized User
 
Join Date: May 2004
Posts: 24
Thanks: 0
Thanked 0 Times in 0 Posts
Default

In body tag code: onbeforeunload="MyUnloadCheck()"

function MyUnloadCheck() {

event.returnValue = "You may have unsaved data ..."
}

The browser will display :

'Do you want to navigate away from this page?'
'You may have unsaved data'
'Hit Ok or cancel'

If you do not return a value in event.returnValue property,
browser will not display the message.
If you want to conditionally return a value if the page is dirty, create a new function on the fly after detecting it is dirty, as follows:
document.body.onbeforeunload=new Function("MyUnloadCheck()")

SS
 
Old May 22nd, 2006, 12:46 AM
Registered User
 
Join Date: May 2006
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Quote:
quote:Originally posted by mehdi62b
 write your code somewhere like Session_End or Dispose methode in your Global.asax file

--------------------------------------------
Mehdi.:)
 
Old May 22nd, 2006, 12:48 AM
Registered User
 
Join Date: May 2006
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default

how to write code in asp when ie close button press(right corner)






Similar Threads
Thread Thread Starter Forum Replies Last Post
Event Handling Apocolypse2005 Visual Basic 2005 Basics 1 March 10th, 2009 07:14 AM
Event Handling C# 2.0 AccessAasif@aol.com C# 2005 2 January 25th, 2008 11:37 AM
Event handling in c# bhavna VS.NET 2002/2003 1 March 7th, 2007 12:19 PM
Event handling in c# bhavna General .NET 1 March 7th, 2007 05:32 AM
Help with Event handling nulogix Java GUI 1 October 11th, 2004 03:55 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.