?
Solved

asp.net page event sequence

Posted on 2011-05-09
7
Medium Priority
?
472 Views
Last Modified: 2012-05-11
I am trying to understand what is happening with respect to event firing.

I have a asp site master and default page.  The default page has an update panel tied to an ajax scriptmaganer timer event.

When I run in debug I see the events fires as follows:
1) default_page unload,
2) default_page load,
3) site_master_page load,
4) site_master_page unload,
5) timer event
6) timer event

So, my questions are,
a) Why is  default_page unload before  default_page load?
b) Why is the timer event executing two times?

0
Comment
Question by:kperelman
  • 3
  • 2
  • 2
7 Comments
 
LVL 18

Expert Comment

by:dj_alik
ID: 35721691
About life cycle of events in Page  you can read from
ASP.NET Page Life Cycle Overview
http://msdn.microsoft.com/en-us/library/ms178472.aspx
Can you post your source?
0
 
LVL 14

Expert Comment

by:CtrlAltDl
ID: 35722599
Which timer event are you talking about (Tick, Load, unload)?

I can't think of any reason why your page_unload would trigger before your page_load event, unless your page was being loaded twice.
0
 

Author Comment

by:kperelman
ID: 35723562
Here is the site master page:

<%@ Master Language="VB" AutoEventWireup="false" CodeFile="Site.Master.vb" Inherits="Site" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head runat="server">
    <title></title>
    <asp:ContentPlaceHolder ID="HeadContent" runat="server">
    </asp:ContentPlaceHolder>
</head>
<body>
    <form runat="server">
        <div class="main">
            <asp:ContentPlaceHolder ID="MainContent" runat="server"/>
        </div>
    </form>
</body>
</html>

Here is the default page:

<%@ Page Title="Home Page" Language="VB" MasterPageFile="~/Site.Master" AutoEventWireup="false"
    CodeFile="Default.aspx.vb" Inherits="_Default" %>

<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="asp" %>

<asp:Content ID="HeaderContent" runat="server" ContentPlaceHolderID="HeadContent">
</asp:Content>
<asp:Content ID="BodyContent" runat="server" ContentPlaceHolderID="MainContent">
    <asp:ToolkitScriptManager ID="ToolkitScriptManager1" runat="server" />
      <div style="position:absolute; left: 330px; top: 0px; height: 500px;">
        <asp:Timer runat="server" ID="Update_Panel_Timer" Interval="4000" Enabled="true" OnTick="Update_Panel_Timer_Tick" />
        <asp:UpdatePanel runat="server" ID="TimedPanel" UpdateMode="Conditional" >
            <Triggers>
                <asp:AsyncPostBackTrigger ControlID="Update_Panel_Timer" EventName="Tick" />
            </Triggers>
            <ContentTemplate>
                <asp:Image ID="Image1" runat="server" style="border: 1px solid black;"  height="440px" Width="315px" />
            </ContentTemplate>
        </asp:UpdatePanel>
    </div>
</asp:Content>

My code behind is simply a vb.net 'stop' for the Tick, Page_unload and Page_load events.  No other code.
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 

Author Comment

by:kperelman
ID: 35753955
I have been working on this and here what I currently see:

When I run in debug I see the events fires as follows:
1) default_page load,
2) default_page unload,
3) site_master_page unload,
4) site_master_page load,

5) default_page load,
6) default_page unload,
7) site_master_page unload,
8) site_master_page load,

9) timer event
10) timer event

So, my questions are,
a) Why is  site_master_page unload before  site_master_page load?
b) Why is the timer event executing two times?

0
 
LVL 18

Expert Comment

by:dj_alik
ID: 35754005
Trace option for ASP.NET control will be useful to inspect event sequence.
Sometimes to understand sequence of events in ASP.NET page, it is useful to set
@page TRACE="true"
0
 

Author Comment

by:kperelman
ID: 35754131
My question is, is this the sequence I should except based on the html pasted above?
0
 
LVL 14

Accepted Solution

by:
CtrlAltDl earned 2000 total points
ID: 35781974
Your masterpage unload should never be before the load event unless the unload event is being called specifically/programatically.

http://msdn.microsoft.com/en-us/library/dct97kc3.aspx
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article discusses the ASP.NET AJAX ModalPopupExtender control. In this article we will show how to use the ModalPopupExtender control, how to display/show/call the ASP.NET AJAX ModalPopupExtender control from javascript, how to show/display/cal…
Introduction This article shows how to use the open source plupload control to upload multiple images. The images are resized on the client side before uploading and the upload is done in chunks. Background I had to provide a way for user…
Integration Management Part 2
Screencast - Getting to Know the Pipeline
Suggested Courses

807 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question