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

Page_Unload event firing twice.

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 around, but I'm
curious how one is supposed to programmatically navigate between web pages
without the page_unload event firing twice.

Thanks,

Larry



Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load

'Put user code to initialize the page here

Stop

End Sub

Private Sub Page_Unload(ByVal sender As Object, ByVal e As System.EventArgs)
Handles MyBase.Unload

Stop

End Sub

Private Sub LinkButton1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles LinkButton1.Click

Response.Redirect("http://www.microsoft.com")

End Sub

End Class
Nov 19 '05 #1
4 6055
As the page is loaded the first time, it will invoke Page_Unload the
first time finally but just before rendering the HTML content to the
browser,

Then the link butten will invoke page postback, in which the
page_unload will be invoked again.

If just want to invoke once, try to use if(IsPostBack) to filter it.
HTH.

T.Z

Nov 19 '05 #2
As the page is loaded the first time, it will invoke Page_Unload the
first time finally but just before rendering the HTML content to the
browser,

Then the link butten will invoke page postback, in which the
page_unload will be invoked again.

If just want to invoke once, try to use if(IsPostBack) to filter it.
HTH.

T.Z

Nov 19 '05 #3
I know that; What happens in this case is:

Page_Load,
Page_Unload,

Page_Load,
LinkButton1_Click,
Page_Unload,
Page_Unload.

Notice the Page_Unload event fired twice. What is it about the
Response.Redirect causes two page_unload events?

"tzeng9" <tz****@gmail.com> wrote in message
news:11**********************@z14g2000cwz.googlegr oups.com...
As the page is loaded the first time, it will invoke Page_Unload the
first time finally but just before rendering the HTML content to the
browser,

Then the link butten will invoke page postback, in which the
page_unload will be invoked again.

If just want to invoke once, try to use if(IsPostBack) to filter it.
HTH.

T.Z

Nov 19 '05 #4
every page request has a load and unload. a redirect in the response tells
the browser to request a new page. page unload has nothing to do with the
browser, its just the last step in the creating the html for the page, it
used to release objects you created during building the page.

-- bruce (sqlwork.com)

"Larry Morris" <lw******@reliasoft.biz> wrote in message
news:et**************@TK2MSFTNGP09.phx.gbl...
| I know that; What happens in this case is:
|
| Page_Load,
| Page_Unload,
|
| Page_Load,
| LinkButton1_Click,
| Page_Unload,
| Page_Unload.
|
| Notice the Page_Unload event fired twice. What is it about the
| Response.Redirect causes two page_unload events?
|
| "tzeng9" <tz****@gmail.com> wrote in message
| news:11**********************@z14g2000cwz.googlegr oups.com...
| > As the page is loaded the first time, it will invoke Page_Unload the
| > first time finally but just before rendering the HTML content to the
| > browser,
| >
| > Then the link butten will invoke page postback, in which the
| > page_unload will be invoked again.
| >
| > If just want to invoke once, try to use if(IsPostBack) to filter it.
| > HTH.
| >
| > T.Z
| >
|
|
Nov 19 '05 #5

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

Similar topics

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...
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...
4
by: Seraph | last post by:
Again, I'm rather new here, so if I fail to follow any etiquette, please forgive me and let me know what I've done wrong, but I think this might interest quite a few people. One of my colleaques...
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....
0
by: Stina | last post by:
I have a problem with the Page_Unload event being called twice in a row on a redirect and I just can't figure out why. I have seen other threads on this subject but not found a solution to the...
2
by: Dan Lichiardopol | last post by:
Hi there! I'm trying to use page unload event in order to write info to a text file. Everything works fine, unless code contains a call to Response.End. Then, the unload event appears to be...
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: 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
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...
0
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,...
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
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,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.