469,355 Members | 2,507 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,355 developers. It's quick & easy.

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 5801
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 discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by Robert Scheer | last post: by
19 posts views Thread by Heidi Hundåla | last post: by
reply views Thread by chefo | last post: by
4 posts views Thread by Seraph | last post: by
7 posts views Thread by Cenk | last post: by
reply views Thread by Stina | last post: by
2 posts views Thread by Dan Lichiardopol | last post: by
5 posts views Thread by =?Utf-8?B?Um9sYW5kcGlzaA==?= | last post: by
1 post views Thread by CARIGAR | last post: by
1 post views Thread by Marylou17 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.