By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
434,677 Members | 1,070 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 434,677 IT Pros & Developers. It's quick & easy.

Page_Unload gets executed twice

P: n/a
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 abstract, because there was some
problem with the compilation. I define a common Page_Unload handler in
the base class and subscribe for the event like this:

public class IPage : System.Web.UI.Page
{
override protected void OnInit(EventArgs e)
{
/* ... */
base.OnInit(e);
this.PreRender += new EventHandler(IPage_PreRender);
this.Load += new EventHandler(IPage_Load);
this.Unload += new EventHandler(IPage_Unload);
}

protected virtual void IPage_Unload(object sender, EventArgs e)
{
if ( IsPostBack )
{
/* ... */
}
}
}
In the derived class unload is not mentioned at all. The first time the
page is loaded IPage_Unload gets executed once. When I click a submit
button the page is posted back to the server, the Page_Load event is
fired, then the button click handler, Page_Unload follows and finally,
gues what... Page_Unload again. Any idea why is this happening? This
is not happening for every page in the project, only for a particular
one and maybe some others. There is little delay between the two
successive Page_Unload executions, less than between Page_Load and
Page_Unload. Any suggestions?

Thanks all

Nov 19 '05 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.