Link to home
Start Free TrialLog in
Avatar of Howard Katz
Howard KatzFlag for United States of America

asked on

Can the user response to the IE7 prompt when closing a window be captured?

Hello Experts,
Is there a way to trap the user response to the prompt IE7 uses when closing a window?  In an asp.net application, code runs when a button is clicked.  This button assumes the user presses "Yes"  ( I want to close the window)  If the user presses "No", I need to be able to do something else.
Thanks
Howard
Avatar of Sachintana Dissanayake
Sachintana Dissanayake
Flag of New Zealand image

Did you try with onunload or onbeforeunload event.

<script type="text/javascript">
<!--
function doUnload()
{
   //do form submission to perform an operation
   formNo.submit();
}

< body onunload="doUnload()">
< /body>
Avatar of Howard Katz

ASKER

Thanks for your quick response....

Here is the situation.  In an asp.net 2.0 application, on a master page there is a asp:button control.  The onClick="btnReleaseRecord_Click"

(see code snippet)

what I would like is that if the user selects No, then the code below
ScriptManager.RegisterClientScriptBlock....NewGuid().ToString, "window.close()", True)

does not fire.

Thanks

 
Protected Sub btnReleaseRecord_Click(..., ...)
 
   ScriptManager.RegisterClientScriptBlock(Page, Page.GetType(),        Guid.NewGuid().ToString, "window.close()", True)
  If Session("OwnerExiting") = "yes" Then
     Application.Remove(Session("QuoteNumber"))
     Application.Remove(Session("QuoteNumber") & "User")
  End If
  Dim ow = Session("OwnerExiting")
  Session.RemoveAll()
  Session("OwnerExiting") = "yes"
 End Sub

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of Sachintana Dissanayake
Sachintana Dissanayake
Flag of New Zealand image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Forced accept.

Computer101
EE Admin