473,378 Members | 1,309 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,378 software developers and data experts.

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.Current.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 3194
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.Current.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.Current.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.Current.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
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...
6
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...
1
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...
1
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...
2
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
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?...
6
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
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...
2
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...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.