473,396 Members | 2,082 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

PAGE_LOAD fired twice

RAJ
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?


Nov 18 '05 #1
2 1453
It happens to that page only or all the pages? Check those properties that
you set for your server controls.
"RAJ" <an*******@discussions.microsoft.com> wrote in message
news:OW**************@TK2MSFTNGP12.phx.gbl...
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?

Nov 18 '05 #2
RAJ
Thanks for your help, Trevor. Its sorted with the help of the URL you
posted.
"Trevor Benedict R" <tr********@yahoo.com> wrote in message
news:58**********************************@microsof t.com...
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?


Nov 18 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Funbeat | last post by:
Hi everybody, I'm facing with the following problem (bug ?) : A page is calling another one (export.aspx) for exporting data to excel. The tecnhique used is to create a Excel-MIME stream...
8
by: Andy | last post by:
Visual Studio 2003 web form problem using C#. My Page_Load or OnInit routines seems to be called twice for every post back to the server. I have 2 web forms that produce this behaviour, all of...
2
by: dx | last post by:
I have a simple user control (.ascx) that is dynamically instantiated in the calling aspx page and added to the control tree (within the page_load.) I have checked and the calling page only...
7
by: Nimrod Cohen | last post by:
Hi During the page_load of my Aspx page "http://myMachine/MyWebApp/Quote.aspx" , i write to the response an html that embeds a form with the action pointing out to the same aspx page i.e...
14
by: V. Jenks | last post by:
I'm a little rusty having not touched .NET for 6 months and I can't remember why Page_Load is happening twice in this code: private void Page_Load(object sender, System.EventArgs e) {...
4
by: Seraph | last post by:
Again, I'm rather new here, so if I fail to follow any etiquette, please forgive me and let me know what I've done wrong, but I think this might interest quite a few people. One of my colleaques...
0
by: pat.allan | last post by:
Hi All This seems to be a common problem here, but I've not found a solution yet to fix it for me. When I request a page through a browser, the page_load fires once. When I request the page's...
1
by: Rippo | last post by:
Hi I have a Master page that opens up a db connection, performs a couple of global routines in the page_load event. All of my other web pages in my web app then inherits this Master Page I...
12
by: Nathan Sokalski | last post by:
What is the difference between the Page_Init and Page_Load events? When I was debugging my code, they both seemed to get triggered on every postback. I am assuming that there is some difference,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.