Solved page event sequence

Posted on 2011-05-09
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?

Question by:kperelman
    LVL 18

    Expert Comment

    About life cycle of events in Page  you can read from
    ASP.NET Page Life Cycle Overview
    Can you post your source?
    LVL 14

    Expert Comment

    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.

    Author Comment

    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" "">
    <html xmlns="" xml:lang="en">
    <head runat="server">
        <asp:ContentPlaceHolder ID="HeadContent" runat="server">
        <form runat="server">
            <div class="main">
                <asp:ContentPlaceHolder ID="MainContent" runat="server"/>

    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 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" >
                    <asp:AsyncPostBackTrigger ControlID="Update_Panel_Timer" EventName="Tick" />
                    <asp:Image ID="Image1" runat="server" style="border: 1px solid black;"  height="440px" Width="315px" />

    My code behind is simply a 'stop' for the Tick, Page_unload and Page_load events.  No other code.

    Author Comment

    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?

    LVL 18

    Expert Comment

    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"

    Author Comment

    My question is, is this the sequence I should except based on the html pasted above?
    LVL 14

    Accepted Solution

    Your masterpage unload should never be before the load event unless the unload event is being called specifically/programatically.

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    How to run any project with ease

    Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
    - Combine task lists, docs, spreadsheets, and chat in one
    - View and edit from mobile/offline
    - Cut down on emails

    One of the pain points with developing AJAX, JavaScript, JQuery, and other client-side behaviors is that JavaScript doesn’t allow for cross domain request for pulling content. For example, JavaScript code on could not pull conte…
    ASP.Net to Oracle Connectivity Recently I had to develop an ASP.NET application connecting to an Oracle database.As I am doing it first time ,I had to solve several problems. This article will help to such developers  to develop an ASP.NET client…
    This video is in connection to the article "The case of a missing mobile phone (". It will help one to understand clearly the steps to track a lost android phone.
    This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor ( If you're looking for how to monitor bandwidth using netflow or packet s…

    759 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

    Need Help in Real-Time?

    Connect with top rated Experts

    11 Experts available now in Live!

    Get 1:1 Help Now