Response.Redirect or a Server.Transfer.
The output below demonstrates that during the move from the first to the 2nd
page, the event fires twice on the 1st page during Postback. The "var" set
the first time is visible the 2nd time it fires.
Anyone else notice this?
Thanks,
Jeff
<Page_Unload, page 1>
private void Page_Unload(object sender, EventArgs e)
{
Debug.WriteLine("Page_Unload in UnloadTestPage1");
Debug.WriteLine("var in UnloadTestPage1's Page_Unload: " + var);
var = "second (reset on first Page_Unload)";
}
</>
<output>
RESPONSE.REDIRECT
Page_Load in UnloadTestPage1
Button1_Click in UnloadTestPage1...Response.Redirect("UnloadTestPag e2.aspx")
Page_Unload in UnloadTestPage1
var set in UnloadTestPage1's Page_Unload: "first (default)"
Page_Unload in UnloadTestPage1
var set in UnloadTestPage1's Page_Unload: "second (reset on first
Page_Unload)"
Page_Load in UnloadTestPage2
Page_Unload in UnloadTestPage2
SERVER.TRANSFER
Page_Load in UnloadTestPage1
Button1_Click in UnloadTestPage1...Server.Transfer("UnloadTestPage2 .aspx")
Page_Load in UnloadTestPage2
Page_Unload in UnloadTestPage2
Page_Unload in UnloadTestPage1
var set in UnloadTestPage1's Page_Unload: first (default)
Page_Unload in UnloadTestPage1
var set in UnloadTestPage1's Page_Unload: second (reset on first Page_Unload)