473,545 Members | 2,705 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Question on Control.Unload event

Hello,

I've an application where all my pages implement a PAGE_CODE string
property, this property is stored in HttpContext.Cur rent.Items.

In some page, I must persist data in session while the user perform
operation on this page (postback navigation based). I also need to
clean up the session data when the user leave the page (by a anyway).

My question is about the Unload event, is it safe to use the unload
event and check if the PAGE_CODE is out of scope to remove session
variables that are used in the unloaded page?

I ask this because after some tests, it happen that unload is trigged
on the next navigation within the same session and I can't find any
clear description on when this event will be trigged on the server side.

Either way, what is your strategy to remove unneeded variables in
session? Does anyone allready use the Unload event?

Thanks for your insight.

Gauthier
Nov 19 '05 #1
3 3203
the Unload for triggered as the last event during the page execution.
Page_Unload is the counterpart to Page_Init .. That also implies, for each
post back the unload events for control and page are being executed.

I doubt if I understand the requirement correctly.. if you are looking for a
way to find if the user is done with a page and is navigating to another page
, there is no event supported for that.. Unloading of a page doesn't happen
when user close the browser or navigate to a different page.

Unload event is good for cleaning up resources used during the page
execution.

"Gauthier Segay" wrote:
Hello,

I've an application where all my pages implement a PAGE_CODE string
property, this property is stored in HttpContext.Cur rent.Items.

In some page, I must persist data in session while the user perform
operation on this page (postback navigation based). I also need to
clean up the session data when the user leave the page (by a anyway).

My question is about the Unload event, is it safe to use the unload
event and check if the PAGE_CODE is out of scope to remove session
variables that are used in the unloaded page?

I ask this because after some tests, it happen that unload is trigged
on the next navigation within the same session and I can't find any
clear description on when this event will be trigged on the server side.

Either way, what is your strategy to remove unneeded variables in
session? Does anyone allready use the Unload event?

Thanks for your insight.

Gauthier

Nov 19 '05 #2
Hello,

thanks for your answer,

I'm not trying to do anything when the user close his browser window,
I'm trying to determinate when the unload event is really trigged and
if it's reliable to use it the way I described.

I'm unsure that the Unload event is trigged at the end of the request,
because in development environment, when I put breakpoint in this event
handler, it's not getting called after the request was sent to the
client browser, but it's effectively trigged on the subsequent request.

I suppose I should investigate another way to maintain/clean session
variables but the fact that the unload event seemed to be trigged on
next postback would have helped because only the page I came from
really knows which session variables have to be removed.

Do you use reliably the Unload event and did it fires just after the
request was sent or on the subsequent postback?

Regards,

Gauthier

Sreejith Ram wrote:
the Unload for triggered as the last event during the page execution.
Page_Unload is the counterpart to Page_Init .. That also implies, for
each post back the unload events for control and page are being
executed.

I doubt if I understand the requirement correctly.. if you are
looking for a way to find if the user is done with a page and is
navigating to another page , there is no event supported for that..
Unloading of a page doesn't happen when user close the browser or
navigate to a different page.

Unload event is good for cleaning up resources used during the page
execution.

"Gauthier Segay" wrote:
Hello,

I've an application where all my pages implement a PAGE_CODE string
property, this property is stored in HttpContext.Cur rent.Items.

In some page, I must persist data in session while the user perform
operation on this page (postback navigation based). I also need to
clean up the session data when the user leave the page (by a
anyway).

My question is about the Unload event, is it safe to use the unload
event and check if the PAGE_CODE is out of scope to remove session
variables that are used in the unloaded page?

I ask this because after some tests, it happen that unload is
trigged on the next navigation within the same session and I can't
find any clear description on when this event will be trigged on
the server side.

Either way, what is your strategy to remove unneeded variables in
session? Does anyone allready use the Unload event?

Thanks for your insight.

Gauthier


Nov 19 '05 #3
A project I worked last year, used custom session management. I think, the
code was written in Page_Unload (of the base page) to write the changes made
to session values to the database. Do not have access to the code to
verify.. I may have used the Dispose . Have you tried 'Dispose' ?

http://msdn.microsoft.com/library/de...nlifecycle.asp
"Gauthier Segay" wrote:
Hello,

thanks for your answer,

I'm not trying to do anything when the user close his browser window,
I'm trying to determinate when the unload event is really trigged and
if it's reliable to use it the way I described.

I'm unsure that the Unload event is trigged at the end of the request,
because in development environment, when I put breakpoint in this event
handler, it's not getting called after the request was sent to the
client browser, but it's effectively trigged on the subsequent request.

I suppose I should investigate another way to maintain/clean session
variables but the fact that the unload event seemed to be trigged on
next postback would have helped because only the page I came from
really knows which session variables have to be removed.

Do you use reliably the Unload event and did it fires just after the
request was sent or on the subsequent postback?

Regards,

Gauthier

Sreejith Ram wrote:
the Unload for triggered as the last event during the page execution.
Page_Unload is the counterpart to Page_Init .. That also implies, for
each post back the unload events for control and page are being
executed.

I doubt if I understand the requirement correctly.. if you are
looking for a way to find if the user is done with a page and is
navigating to another page , there is no event supported for that..
Unloading of a page doesn't happen when user close the browser or
navigate to a different page.

Unload event is good for cleaning up resources used during the page
execution.

"Gauthier Segay" wrote:
Hello,

I've an application where all my pages implement a PAGE_CODE string
property, this property is stored in HttpContext.Cur rent.Items.

In some page, I must persist data in session while the user perform
operation on this page (postback navigation based). I also need to
clean up the session data when the user leave the page (by a
anyway).

My question is about the Unload event, is it safe to use the unload
event and check if the PAGE_CODE is out of scope to remove session
variables that are used in the unloaded page?

I ask this because after some tests, it happen that unload is
trigged on the next navigation within the same session and I can't
find any clear description on when this event will be trigged on
the server side.

Either way, what is your strategy to remove unneeded variables in
session? Does anyone allready use the Unload event?

Thanks for your insight.

Gauthier


Nov 19 '05 #4

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

Similar topics

1
3019
by: mjcast | last post by:
I have been working on an ActiveX control in C#. It is packaged in a Windows Control library and the code is in a user control. The control is used as an automation receiver that is used to update a page dynamically through the use of event listeners in javascript That works, the problem is that when I run the test webpage that runs the ActiveX...
6
1782
by: David Sullivan | last post by:
Hi I have a problem with a database where certain users are closing access (by clicking on the X in top right-hand corner) instead of using a command button before they fill in all relevant fields. Q. Is there a way of not allowing them to exist access using the this way and use the command button? Thanks in Advance
1
2635
by: hal | last post by:
I have an application that includes an activex component that consumes resources that must be released when the a page is unloaded. Toward this end I subscribe to the unload event of the body of my page in javascript. However, if I turn on smart navigation, any button that does a server.transfer fails to fire the javascript unload event.
1
2920
by: Hal | last post by:
My most sincere gratitude to anyone who can help me work around this! I have work that needs to be done in javascript on the client whenever a page is unloaded. To this end, I subscribe to the unload event (client side not server side) of the <body> HTML element through javascript.
2
3608
by: John Lau | last post by:
Hi, Is there documentation that talks about the page lifecycle, the lifecycle of controls on the page, and the rendering of inline code, in a single document? Thanks, John
0
1108
by: bburkhart | last post by:
I am running into a issue catching a thrown error in the Control.Unload event. Is it possible to throw an Application error from the Unload event and have the global.asax Application_Error catch it? Here is a code sample, this is in my PageBase.cs private void InitializeComponent() { this.Unload += new System.EventHandler(this.Page_UnLoad);...
6
2196
by: Shimon Sim | last post by:
I have Panel control on the page. I am handling Init event for it. It doesn't seem to fire at all. Why? Thank you Shimon.
13
1970
by: PW | last post by:
Hi, This is bizarre. I've check and rechecked the spelling, cut and paste the name of the form (when trying to rename the form) and the control yet I still get a parameter prompt when the form runs. I've even deleted the control and started over. This is the code for the recordsource of the form: "SELECT * FROM...
2
1674
by: =?Utf-8?B?TWlrZSBDb2xsaW5z?= | last post by:
I have a web app that when I click a menu, I load a control. On one of these controls, I have a button that when clicked, I need to unload the control to unload itself and load a different control in its place. I am not sure how to do this from within a control itself. Can anyone offer any help and show me what I am doing wrong with my code...
0
7499
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7432
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7943
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7456
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
6022
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
0
5076
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3470
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1919
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1044
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.