Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

Hi all !

 

Is there a way to catch the unload event when someone close the IE window with the "X" ? I tried JS in Body onunload but it's not working. I just want to ask a confirmation message before he close the window. If the answer is yes, just close the window, otherwise cancel the close event.

 

Is it possible ?

Now go on, boy, and pay attention. Because if you do, someday, you may achieve something that we Simpsons have dreamed about for generations: You may outsmart someone!

--Homer Simpson

Posted

Maybe have a "close" button. Then if users click that, popup a msg if they want to close...

 

My JS looks like this:

 


<script language="javascript">
	 function confirm_delete()
{
 if (confirm("Are you sure you want to delete the Activity?")==true)
   return true;
 else
   return false;
}
	
	</script>

 

My button looks like this:

 

<asp:Button Runat="server" Font-Bold="True" BackColor="Red" ID="btnDelete" CommandName="Delete" Text="Delete Activity"></asp:Button>

 

 

Then in the code behind:

 


       If e.Item.ItemType = ListItemType.Item Or e.Item.ItemType = ListItemType.AlternatingItem Then
           Dim _myButton As Button = CType(e.Item.FindControl("btnDelete"), Button)
           Dim test = _myButton.Text
           _myButton.Attributes.Add("onclick", "return confirm_delete();")
       End If

Posted
Thanks eramgarden, I know this would work. But still, it won't prevent the user from using the "X"....

Now go on, boy, and pay attention. Because if you do, someday, you may achieve something that we Simpsons have dreamed about for generations: You may outsmart someone!

--Homer Simpson

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...