Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > PAGE_LOAD fired twice

Reply
Thread Tools

PAGE_LOAD fired twice

 
 
RAJ
Guest
Posts: n/a
 
      06-08-2004
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?




 
Reply With Quote
 
 
 
 
chanmmn
Guest
Posts: n/a
 
      06-08-2004
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?
>
>
>
>



 
Reply With Quote
 
 
 
 
RAJ
Guest
Posts: n/a
 
      06-10-2004
Thanks for your help, Trevor. Its sorted with the help of the URL you
posted.


"Trevor Benedict R" <> wrote in message
news:583DF445-8464-41A5-BAF4-...
> Checkout
>
> http://www.extremeexperts.com/Net/FA...ringTwice.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?
>
>
>
>
>



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Materpage page_load event fired after content page_load? rockdale ASP .Net 1 11-16-2006 06:59 PM
template page page_load fired twice Rippo ASP .Net 1 08-17-2005 01:04 PM
Page_Load fired twice via ProcessRequest pat.allan@gmail.com ASP .Net 0 06-23-2005 08:52 AM
Page_Load being fired twice =?Utf-8?B?Tmltcm9kIENvaGVu?= ASP .Net 7 06-09-2004 01:47 PM
Why does page_load fire twice when inheriting from a common overridable Page_Load bminder ASP .Net 1 02-23-2004 08:54 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57