473,396 Members | 1,891 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

web app page_unload

Hi, I have created a asp.net web application and I hooked up page_unload so
I can clean up some things when i close it down.
The problem is, page_unload gets called when I first load the page, not when
I close it.
I know this because I put a breakpoint within the method, and it stops when
i first run it, not when I close.

private void Page_Unload(object sender, System.EventArgs e)
{
System.Diagnostics.Debug.WriteLine("closing");
}

private void InitializeComponent()
{
this.btnAdopt.Click += new System.EventHandler(this.btnAdopt_Click);
this.Load += new System.EventHandler(this.Page_Load);
this.Unload += new System.EventHandler(this.Page_Unload);
}

Any Ideas?
Thanks.
Nov 16 '05 #1
3 9978
James:

The Load and Unload events both fire during the browser request to the server.
In other words, you point your browser to the URL for a web form, and when
the page is executing the Load and Unload events both fire at that time.
By the time the browser display the HTML the web form has finished the job
and there are no more events to fire. The server and the browser are disconnected.
--
Scott
http://www.OdeToCode.com/blogs/scott/
Hi, I have created a asp.net web application and I hooked up
page_unload so
I can clean up some things when i close it down.
The problem is, page_unload gets called when I first load the page,
not when
I close it.
I know this because I put a breakpoint within the method, and it stops
when
i first run it, not when I close.
private void Page_Unload(object sender, System.EventArgs e)
{
System.Diagnostics.Debug.WriteLine("closing");
}
private void InitializeComponent()
{
this.btnAdopt.Click += new System.EventHandler(this.btnAdopt_Click);
this.Load += new System.EventHandler(this.Page_Load);
this.Unload += new System.EventHandler(this.Page_Unload);
}
Any Ideas?
Thanks.

Nov 16 '05 #2
James Hawthorne wrote:
Hi, I have created a asp.net web application and I hooked up page_unload so
I can clean up some things when i close it down.
The problem is, page_unload gets called when I first load the page, not when
I close it.
I know this because I put a breakpoint within the method, and it stops when
i first run it, not when I close.

The Unload event is raised when ASP.NET unloads the page from memory.
This happens every time the page is requested. To handle the client side
window.close event you'll have to use client side script.

Anders Norås
http://dotnetjunkies.com/weblog/anoras/
Nov 16 '05 #3
On Thu, 06 Jan 2005 13:10:14 GMT, James Hawthorne wrote:
Hi, I have created a asp.net web application and I hooked up page_unload so
I can clean up some things when i close it down.
The problem is, page_unload gets called when I first load the page, not when
I close it.
I know this because I put a breakpoint within the method, and it stops when
i first run it, not when I close.

private void Page_Unload(object sender, System.EventArgs e)
{
System.Diagnostics.Debug.WriteLine("closing");
}

private void InitializeComponent()
{
this.btnAdopt.Click += new System.EventHandler(this.btnAdopt_Click);
this.Load += new System.EventHandler(this.Page_Load);
this.Unload += new System.EventHandler(this.Page_Unload);
}

Any Ideas?
Thanks.


The page Unload event fires when the page object on the server is unloaded.
This will almost never correspond with when you close the page in your
browser window. The page object is created on the server when the page is
requested. Once the page object has processed everything and the HTML
stream has been sent to the browser, the server is basically then done with
the page object and it is unloaded. You can then hold the browser window
open as long as you like, but since that is just on the client machine
there are no server resources needed.
--
Tom Porterfield
Nov 16 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: tascien | last post by:
I found a use for Page_Unload event method... here is the scenario: 1. Page.aspx has DoStuff.ascx in it. 2. DoStuff.ascx has a button that updates child control label lbXml depending on user...
1
by: Robert Scheer | last post by:
Hi. Debugging one of my pages I noticed that everytime I call the page, the first event to run is Page_Load and after it the Page_Unload. If I postback to the page the Page_Unload runs again....
19
by: Heidi Hundåla | last post by:
Hi ! I have a Wep App in C#. Page_Unload fires after Page_Load, and it seems totally unreasonable when you want to use this event when you _leave_ the page. In my project we wanted to use...
4
by: Larry Morris | last post by:
The following code, pasted into a web form with a link button on it, will cause the page_unload event to fire twice. If I remove the response.redirect, the problem goes away :). I've got a work...
3
by: Andrew Vickers | last post by:
Hi, I'm just trying to manually add a page_unload function in my code-behind module, but with no success. Can anyone help me with the correct syntax to add the function to my code? I've tried...
0
by: chefo | last post by:
Well, the subject describes my problem quite well :-) Here is some additional information. I use a common base class for all the pages in my project. It is derived from Page and it is not...
0
by: JeffM | last post by:
This seems odd, but it appears that the Page_Unload event is fired twice on a Response.Redirect or a Server.Transfer. The output below demonstrates that during the move from the first to the 2nd...
7
by: Cenk | last post by:
Hi, After converting my projects to ASP.Net 2.0 I have seen a problem with Page_unload. Ä°n framework 1.1 page_unload event fires when you are leaving the page or has closed the browser window....
2
by: RAM | last post by:
Hello, I am learning .NET 2.0 and I have written simple application with Default.aspx page and logging in Logon.aspx/Logon.aspx.cs. After Page_Unload of Logon.aspx.cs (I have checked by debugging)...
5
by: =?Utf-8?B?Um9sYW5kcGlzaA==?= | last post by:
Hi there, I'm using Web Developer Express 2005 in my ASP.NET learning. I tried creating a simple aspx page using "code-behind" approach. I noticed that protected void Page_Load event method...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.