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
Howard KatzDatabase Report DeveloperAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Sachintana DissanayakeSenior Web DeveloperCommented:
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>
0
Howard KatzDatabase Report DeveloperAuthor Commented:
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

0
Sachintana DissanayakeSenior Web DeveloperCommented:
Just put alert instead of window.close() and check whether its registering the javascript properly.
     ScriptManager.RegisterClientScriptBlock(Page, Page.GetType(), Guid.NewGuid().ToString, "javascript:alert('test alert');", True)

I recommend you to move the javascript content (even single line) to a function and call the function above.
    "javascript:alertFunction();"
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Computer101Commented:
Forced accept.

Computer101
EE Admin
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Web Browsers

From novice to tech pro — start learning today.