Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > .NET > Other .NET > General .NET
Password Reminder
Register
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developersí questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Display Modes
  #1 (permalink)  
Old August 9th, 2004, 01:15 AM
Authorized User
 
Join Date: Feb 2004
Location: Delhi, Delhi, India.
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.


-.. -..
__________________
-.. -..
Reply With Quote
  #2 (permalink)  
Old August 9th, 2004, 03:48 AM
Friend of Wrox
 
Join Date: Jul 2004
Location: Tehran, , Iran.
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.:)
Reply With Quote
  #3 (permalink)  
Old August 9th, 2004, 09:47 AM
planoie's Avatar
Friend of Wrox
Points: 16,481, Level: 55
Points: 16,481, Level: 55 Points: 16,481, Level: 55 Points: 16,481, Level: 55
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Aug 2003
Location: Clifton Park, New York, USA.
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
Reply With Quote
  #4 (permalink)  
Old August 9th, 2004, 10:21 AM
Authorized User
 
Join Date: May 2004
Location: , , USA.
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
Reply With Quote
  #5 (permalink)  
Old May 22nd, 2006, 01:46 AM
Registered User
 
Join Date: May 2006
Location: , , .
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.:)
Reply With Quote
  #6 (permalink)  
Old May 22nd, 2006, 01:48 AM
Registered User
 
Join Date: May 2006
Location: , , .
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default

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

Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Event Handling Apocolypse2005 Visual Basic 2005 Basics 1 March 10th, 2009 08: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 04:55 PM



All times are GMT -4. The time now is 06:34 AM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.