.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Gaurav Pal
Post New Web Links

Catch Browser Close Event, but how?

Posted By:      Posted Date: October 01, 2010    Points: 0   Category :ASP.Net

I want to call a function in my Global.asax when the user closes his browser so I can delete a databse entry but how do I have to do this?


View Complete Post

More Related Resource Links

WebDev.WebServer.exe has encounted a problem and needs to close when trying to view page in browser


Hi, whenever I load an aspx page in vwde2008, I get the message in the subject of this post.  After I click Ok on that, I get a dialog box, Unable to Connect to the ASP.Net development center.  What can I do to troubleshoot?

I am using Windows XP SP3, vwde2008 with SP1, on a HP desktop.  Also using Office 2003 if that is relevant at all.

Thanks, Justin

Catch button click event in different .aspx page.


I have a button which starts processing.
I want that when ever a button is click from page1.aspx .. a count down timer should start and displayed on page2.aspx.
I am thinking of using iframe to join 2 pages.

Please let me know your suggestions.


Is it possible for one thread to catch an event thrown by another thread?

I have a very simple class (shown below) that monitors the mouse position on a separate thread to see if it is hovering over the same spot for more than a second.  I have to do this because the Windows Forms control I am using is an interop COM component that does not have or implement the MouseHover event. Anyway, the class that instantiates asrMouseHover (lets call it WinFormMain) adds a handler for the asrMouseHover.MouseIsHovering event.  The problem is, when this event is raised and caught, the handler in WinFormMain is running on the same thread as asrMouseHover.  I need it to run on WinFormMain... hence, is it possible for one thread to catch an event thrown by another thread.    Public Class asrMouseHover Public Event MouseIsHovering(ByVal sender As Object, ByVal e As System.EventArgs) Private _timer As System.Threading.Timer Private _xCoord As Int32 = 0 Private _yCoord As Int32 = 0 Public ReadOnly Property XCoord() As Double Get Return _xCoord End Get End Property Public ReadOnly Property YCoord() As Double Get Return _yCoord End Get End Property Sub New() Dim myTimerCallback As System.Threading.TimerCallback = New TimerCallback(AddressOf MyCallbackMethod) _timer = New System.Threading.Timer(myTimerCallback, Nothing, 1000, 1000) End Sub Sub MyCallbackMethod(ByVal s

Is there a close event for the PopupControlExtender?

I'm looking for an event like onclose when the PopupControlExtender closes itself when a user clicks outside the popup.Couldn't think of any! Any help is appreciated.

How to catch Save Ribbon event from code-behind for the custom webpart

Hi there, How can a custom web part(sitting on top of PDP) catch the Save Ribbon event from code? I’ve been looking around for solution, but not yet find one…. Thank you, —JoeJoe

Catch Save Ribbon Event from code-behind for webpart control

Hi there, How can a custom web part catch the Save Ribbon event from code-behind? Thank you, —JoeJoe

Catch Save Ribbon Event from code-behind for webpart control

Hi there, How can a custom web part catch the Save Ribbon event from code-behind? Thank you, —JoeJoe

Create an Event Handler to catch calls to Create.aspx

Hi, I want to research creating an event handler/reciever to catch calls (mouse clicks) to Create.aspx to prevent users having the ability to create new content. I've noticed in VS2010 the templates for Event Recivers you do not get anything similar that I could use as a starting point (List Events, List Item Events etc) Any ideas how I can define a new type of event receiver?

opening a web browser without opening form on windows form load event

Hello All, I have a main frame which has a display button. after clicking on display button I usually open a windows forms. Now I have a requirement to open a web page after clicking on display button. I should not show windows form to the user. for that I had written following code in the Form_int (override) event of windows form. System.Diagnostics.Process.Start(http://www.google.com); and I commented out ShowDisplay(); code.  Everything looks good till now and when I run the project and clicked on display button web browser has been opened, but if I click again another web browser is being opening. but I don't want another browser to be opened. can anybody please help me in that. Thanks in advance.

Will Session_End event will be fired evenif somebody directly closes browser without sign out?

Hi,     In one of my application I m using InProc session state.Can anybody tell me if user closes the browser directly,then Session_End will be called? Regards, Mehul

When establishing a connection with a SQL databse using a try catch Does the try catch close the dat

HI everyone,  I have read a lot about SQL and I am told always to close the connection to the database after you finish. But what happens when you use a try catch and an error oucurs that bypasses the close statement? Since the SQL is enclosed in the try catch you cannot close the connection. Does the try catch close the connection automaticaly?  If it needs to be closed how would you close it? CurtisAlways Lost in Code, Always mark answers as correct if they answer you question and solve your problem. This way others when searching for similar problems can find the answer faster.

how to show popup when we close the browser

i want the wen i close the browser a popup should come confirm r u sure u 
want 2 exit if yes the browser should close and current date should be saved into the database.
i have tryied a code as
protected void Page_UnLoad(object sender, EventArgs e)

DateTime d = System.DateTime.Now;
string cn = "Data Source=hcl;Initial Catalog=mydata;Integrated Security=True";
SqlConnection con = new SqlConnection(cn);
SqlCommand cmd = new SqlCommand("insert into mydate values(@d)", con);
cmd.CommandType = CommandType.Text;
cmd.Parameters.Add(new SqlParameter("@d", d));
// cmd.Parameters.Add(new SqlParameter("@b", b));


but it was not succesful also before i close the browser the data is saved in the database.also i dont know how to call alert function 
as r u sure u want to exit .plz help

How to Trap a "Page Back" or "Page Close" or "Tab Close" Event


 VWD 2008 Express.  Visual Basic.

I have seen pages on the net that when you try to navigate away, they pop up a message asking whether you really want to navigate away.  How can I accomplish this to detect someone hitting the "page back" arrow in a browser or the "x" that closes a browser page or when someone tries to close a browser tab?  Thanks for the help.

catch the html button click event on a class file including html text box value.


I want to catch the html button click event on a class file including html text box value..

<p><input name="" type="text"  value="Enter Name*"/></p>
<p><input name="" type="text"  value="Enter Email*"/></p>

  <input name="Input" type="submit" value="Submit" />

plz tell me how can i do this..

Getting Exception info from catch block to Application_Error event of HttpModule


I need some help regarding one issue I am facing. I created a httpmodule for hadling the unhandled errors and I need to log those errors using log 4 net in database.

Everting working fine but I am not getting any error information once the error was hadled and I need that info too. I want to make it as a centralize module which can trap all errors and log those errors.

How call application_error event of httpmodule from catch block...so that I can log that info there and I no need log in every catch block..


How to close individually the multiple open browser window using c# code?


Hello guys,

The scenario is I have multiple open browser window (IE or Firefox) then I want to close the specific browser individually.

I have tried to lookup the applications running from the task manager but I can't get the running application from the task manager > application > task.

I have added two references below to lookup the task running applications.

using System.Diagnostics;
using System.Threading;

Anyone can help me on how to close individually the specific open browser window using c# code event.


How to know whether the close button on browser has been clicked


Hi All,

 I want to perform some session and application related activities on server side, when the close button of browser is clicked.


1. I have handled it using 'OnBeforeUnload' in body tag of master page

2. but it is getting fired for even if the end user navigates to other page.

3. so my requirement is to call the code on server side, only iff, the close button of the browser is clicked.

Thanks in Advance..


Hi guys,

This is still unsolved problem. Because according to mudassarkhan, if i apply his solution, then everything is ok.

but when the page is regreshed, the value of clicked variable becomes false and undesired action happens once again.

Please come with some solution..guys..

ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend