Timer on master page causes the child page to go through its page

Discussion in 'ASP .Net' started by Luai24, May 6, 2009.

  1. Luai24

    Luai24 Guest

    I have a timer on my parent master page that checks for certain events and
    updates controls that I want through an updatePanel.

    I have numerous child pages that inherit from the master page.

    I get the desired effect of the timer checking for some event and updating
    the controls I specified.

    The undesired effect is the timer will go through the selected(In View)
    child page --- page life cycle.

    So if I have a code in my Page_Init or
    Page_Load event handlers whatever is in them gets executed.

    Doesn't render the html because it is a call back and only updates the
    control I specified like I wanted but, It seems unnessary that It goes
    through the page lifecycle of the child page.

    I do logging in the methods I have in some of these page life cycle stages
    and If I happen to leave my user agent with a view of one of this pages, it
    will be logging every interval that the timer is set to. That is not desired.

    Here is a pseudo example

    Master Page aspx = Timer set to interval 30 sec , And Update panel with
    updatemode set to conditional

    Master code behind = Page_load checkforEvent and if true update the panel.


    Child page 1 inherits from Master page

    Page load = Do something specific to the page and nothing to do with timer ,
    by the way log what you do


    Child Page 2 inherits from Master page

    Page load = Do something specific to the page and nothing to do with
    timer,by the way log what you do


    My expected result is ,

    Go through page load and other page life cycles of the of the master page
    but not the children.

    Apparently that is not the case.

    Question is, How Can I stop the timer from firing my child page event

    The sender in the page load of the child says it is the child page not the
    timer, so I cant say if timer skip what it usually does.

    I also can't set a flag in the master page , like a session var to flag the
    timer because in ASP.net the child fires before the Master.

    This is all expected behaviour

    One sugestion I had from asp.net forums was to use .....
    if (! ScriptManager.IsInAsyncPostBack) {//call the function}
    It would have been nice but my script manager is in the master page and it
    returns true for every ajax request , regardless of who the trigger is.

    So my code in child page_load never executes if I wrapped it with the "if"
    above, since most of my pages are ajaxified.

    What I really need is a way to know who the sender is, if it is the timer
    then i can skip the code in my child page_load.

    But the sender comes in as page itself, not the real sender which is the
    timer. that might have to do with the fact that child page loads before

    How exactly can I tell the Timer (in the master) is the sender from my child

    Luai24, May 6, 2009
    1. Advertisements

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Doug McCann
    William Brogden
    Aug 5, 2004
  2. Jeff Rodriguez
    David Schwartz
    Dec 9, 2003
  3. thunk
    Mar 30, 2010
  4. thunk
    Apr 1, 2010
  5. thunk
    Apr 3, 2010