PAGE_LOAD fired twice

Discussion in 'ASP .Net' started by RAJ, Jun 8, 2004.

  1. RAJ

    RAJ Guest

    Posting this thread again, can somebody please help me with this. Thanks.

    This event appears to be invoked twice for absolutely no reason on only one
    of my ASP.Net web user controls. Although I've now overcome the problem by
    overriding the base classes OnLoad routine, I could never figure out why
    this event was being invoked twice.

    Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
    System.EventArgs) Handles MyBase.Load
    'Put user code to initialize the page here

    End Sub

    It inherits from the following superclass:
    System.Web.UI.UserControl

    This is the scenario:

    When this 'Page_Load' routine was invoked; the call stack as soon as the
    procedure begins shows (when non-user code was viewed) that the base classes
    OnLoad routine invoked (by doing what ever it does) it.

    The strange thing happened when the routine was exiting; I even removed ALL
    of the code from the routine and debugged it whilst dissassembly was shown,
    and as soon as the routine exited (via the assembler instruction RET 4) the
    routine would IMMEDIATELY invoke again!!!

    INFACT, the routine didn't even exit! it immediately went back to the top of
    the routine and ran again.

    The second time it would reach the end of the procedure (instruction RET 4
    again) and would correctly return back to the calling method (OnLoad).

    This appeared to be completely unpredictable behaviour; as the containing
    code was getting executed twice (since i am expecting only 1 page_load per
    build/teardown per object).

    I can only theorise that somewhere, unless its a logic error of my own (but
    I tested it in a seperate ASP Page, with just the user control removing
    LOADS of code to test it; still did it) that its unpredictable behaviour
    caused by event handling references.

    What I would like to know is this:

    Is there any advantages/disadvantages to just overiding the base classes
    OnLoad routine?

    One obvious advantage is you can chose when to invoke the base classes
    OnLoad routine to continue normal processing. But I can't find any
    disadvantages!

    Secondly, has anyone else experienced such behaviour?
    RAJ, Jun 8, 2004
    #1
    1. Advertising

  2. RAJ

    chanmmn Guest

    It happens to that page only or all the pages? Check those properties that
    you set for your server controls.


    "RAJ" <> wrote in message
    news:...
    > Posting this thread again, can somebody please help me with this. Thanks.
    >
    > This event appears to be invoked twice for absolutely no reason on only

    one
    > of my ASP.Net web user controls. Although I've now overcome the problem by
    > overriding the base classes OnLoad routine, I could never figure out why
    > this event was being invoked twice.
    >
    > Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
    > System.EventArgs) Handles MyBase.Load
    > 'Put user code to initialize the page here
    >
    > End Sub
    >
    > It inherits from the following superclass:
    > System.Web.UI.UserControl
    >
    > This is the scenario:
    >
    > When this 'Page_Load' routine was invoked; the call stack as soon as the
    > procedure begins shows (when non-user code was viewed) that the base

    classes
    > OnLoad routine invoked (by doing what ever it does) it.
    >
    > The strange thing happened when the routine was exiting; I even removed

    ALL
    > of the code from the routine and debugged it whilst dissassembly was

    shown,
    > and as soon as the routine exited (via the assembler instruction RET 4)

    the
    > routine would IMMEDIATELY invoke again!!!
    >
    > INFACT, the routine didn't even exit! it immediately went back to the top

    of
    > the routine and ran again.
    >
    > The second time it would reach the end of the procedure (instruction RET 4
    > again) and would correctly return back to the calling method (OnLoad).
    >
    > This appeared to be completely unpredictable behaviour; as the containing
    > code was getting executed twice (since i am expecting only 1 page_load per
    > build/teardown per object).
    >
    > I can only theorise that somewhere, unless its a logic error of my own

    (but
    > I tested it in a seperate ASP Page, with just the user control removing
    > LOADS of code to test it; still did it) that its unpredictable behaviour
    > caused by event handling references.
    >
    > What I would like to know is this:
    >
    > Is there any advantages/disadvantages to just overiding the base classes
    > OnLoad routine?
    >
    > One obvious advantage is you can chose when to invoke the base classes
    > OnLoad routine to continue normal processing. But I can't find any
    > disadvantages!
    >
    > Secondly, has anyone else experienced such behaviour?
    >
    >
    >
    >
    chanmmn, Jun 8, 2004
    #2
    1. Advertising

  3. RAJ

    RAJ Guest

    Thanks for your help, Trevor. Its sorted with the help of the URL you
    posted.


    "Trevor Benedict R" <> wrote in message
    news:...
    > Checkout
    >
    > http://www.extremeexperts.com/Net/FAQ/PageLoadFiringTwice.aspx
    >
    > Regards
    >
    > Trevor Benedict R
    > MCSD
    >
    > ----- RAJ wrote: -----
    >
    > Posting this thread again, can somebody please help me with this.

    Thanks.
    >
    > This event appears to be invoked twice for absolutely no reason on

    only one
    > of my ASP.Net web user controls. Although I've now overcome the

    problem by
    > overriding the base classes OnLoad routine, I could never figure out

    why
    > this event was being invoked twice.
    >
    > Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
    > System.EventArgs) Handles MyBase.Load
    > 'Put user code to initialize the page here
    >
    > End Sub
    >
    > It inherits from the following superclass:
    > System.Web.UI.UserControl
    >
    > This is the scenario:
    >
    > When this 'Page_Load' routine was invoked; the call stack as soon as

    the
    > procedure begins shows (when non-user code was viewed) that the base

    classes
    > OnLoad routine invoked (by doing what ever it does) it.
    >
    > The strange thing happened when the routine was exiting; I even

    removed ALL
    > of the code from the routine and debugged it whilst dissassembly was

    shown,
    > and as soon as the routine exited (via the assembler instruction RET

    4) the
    > routine would IMMEDIATELY invoke again!!!
    >
    > INFACT, the routine didn't even exit! it immediately went back to the

    top of
    > the routine and ran again.
    >
    > The second time it would reach the end of the procedure (instruction

    RET 4
    > again) and would correctly return back to the calling method

    (OnLoad).
    >
    > This appeared to be completely unpredictable behaviour; as the

    containing
    > code was getting executed twice (since i am expecting only 1

    page_load per
    > build/teardown per object).
    >
    > I can only theorise that somewhere, unless its a logic error of my

    own (but
    > I tested it in a seperate ASP Page, with just the user control

    removing
    > LOADS of code to test it; still did it) that its unpredictable

    behaviour
    > caused by event handling references.
    >
    > What I would like to know is this:
    >
    > Is there any advantages/disadvantages to just overiding the base

    classes
    > OnLoad routine?
    >
    > One obvious advantage is you can chose when to invoke the base

    classes
    > OnLoad routine to continue normal processing. But I can't find any
    > disadvantages!
    >
    > Secondly, has anyone else experienced such behaviour?
    >
    >
    >
    >
    >
    RAJ, Jun 10, 2004
    #3
    1. Advertising

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. bminder
    Replies:
    1
    Views:
    2,155
    nfedin
    Feb 23, 2004
  2. =?Utf-8?B?Tmltcm9kIENvaGVu?=

    Page_Load being fired twice

    =?Utf-8?B?Tmltcm9kIENvaGVu?=, May 27, 2004, in forum: ASP .Net
    Replies:
    7
    Views:
    729
    Steven Cheng[MSFT]
    Jun 9, 2004
  3. Replies:
    0
    Views:
    604
  4. Rippo
    Replies:
    1
    Views:
    508
    Scott Allen
    Aug 17, 2005
  5. rockdale
    Replies:
    1
    Views:
    650
    =?Utf-8?B?UGV0ZXIgQnJvbWJlcmcgW0MjIE1WUF0=?=
    Nov 16, 2006
Loading...

Share This Page