473,499 Members | 1,738 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

To really understand the Page_Load event

Dear colleagues,
I kindly ask the C# developers community to help me to REALLY understand
the Page_Load event, so to REALLY have it under control.

Reason for this question is that I cannot anymore accept passively the
behavior of the “Web Form Designer” automatically generated code because of
the fact that, in some circumstances (that I can reproduce at will), my code
is victim of a Page_Load multiple “firing”. In other words the Page_Load
event handler inexplicably enters more than once and, at the second entry,
Login credentials are asked again interactively. With disruptive effects for
my current project.

Let me begin this discussion with what I certainly do not know, or I do not
know for sure.
P1) I do not know what really triggers the OnInit event, beyond the fact
that it is overridden in the “Web Form Designer” automatically generated code
(see hereafter).
P2) I do not know what really the original base.OnInit(e) at last will do.
Indeed I’ve found documentation only about Control.OnInit, but I’m not
convinced it can apply to this case, where no server control in involved
(please see next point), and such an article, as the “ASP.NET Server Control
Event Model”, doesn’t exactly apply. Does it?
P3) Consider that, by definition, “events associated with server controls
are raised on the client but handled on the Web server by the ASP.NET page
framework”. Here the case of OnInit, of an .aspx Web page, is rather
different, isn’t it? Indeed the OnInit event happens BEFORE the presence of
the Web page on the client computer, indeed this is the very event of posting
a page from the server to the client. And this event shouldn’t happen again
until I deliberately ask for another .aspx page. Shouldn’t it? But, alas, it
DOES happen, out of my control. And all that is precisely the reason of this
call “To really understand the Page_Load event”.

As you see I’m really confused (and baffled too…).
Thanks for your time.
P.M.

- - - - -=- - - - -=- - - - -=
“Web Form Designer” automatically generated code:

#region Web Form Designer generated code
override protected void OnInit(aS.EventArgs e) {
//
// CODEGEN: This call is required by the ASP.NET Web Form Designer.
//
InitializeComponent();
base.OnInit(e);
}

/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>

private void InitializeComponent() {
this.Load += new System.EventHandler(this.Page_Load);
}
#endregion

Nov 16 '05 #1
3 2662
this might help you

http://msdn.microsoft.com/library/de...us/cpguide/htm
l/cpconControlExecutionLifecycle.asp
--
HTH

Ollie Riches
http://www.phoneanalyser.net

Disclaimer: Opinions expressed in this forum are my own, and not
representative of my employer.
I do not answer questions on behalf of my employer. I'm just a programmer
helping programmers.

"Studio P.M." <St******@discussions.microsoft.com> wrote in message
news:D8**********************************@microsof t.com...
Dear colleagues,
I kindly ask the C# developers community to help me to REALLY understand the Page_Load event, so to REALLY have it under control.

Reason for this question is that I cannot anymore accept passively the
behavior of the "Web Form Designer" automatically generated code because of the fact that, in some circumstances (that I can reproduce at will), my code is victim of a Page_Load multiple "firing". In other words the Page_Load
event handler inexplicably enters more than once and, at the second entry,
Login credentials are asked again interactively. With disruptive effects for my current project.

Let me begin this discussion with what I certainly do not know, or I do not know for sure.
P1) I do not know what really triggers the OnInit event, beyond the fact
that it is overridden in the "Web Form Designer" automatically generated code (see hereafter).
P2) I do not know what really the original base.OnInit(e) at last will do. Indeed I've found documentation only about Control.OnInit, but I'm not
convinced it can apply to this case, where no server control in involved
(please see next point), and such an article, as the "ASP.NET Server Control Event Model", doesn't exactly apply. Does it?
P3) Consider that, by definition, "events associated with server controls
are raised on the client but handled on the Web server by the ASP.NET page
framework". Here the case of OnInit, of an .aspx Web page, is rather
different, isn't it? Indeed the OnInit event happens BEFORE the presence of the Web page on the client computer, indeed this is the very event of posting a page from the server to the client. And this event shouldn't happen again until I deliberately ask for another .aspx page. Shouldn't it? But, alas, it DOES happen, out of my control. And all that is precisely the reason of this call "To really understand the Page_Load event".

As you see I'm really confused (and baffled too.).
Thanks for your time.
P.M.

- - - - -=- - - - -=- - - - -=
"Web Form Designer" automatically generated code:

#region Web Form Designer generated code
override protected void OnInit(aS.EventArgs e) {
//
// CODEGEN: This call is required by the ASP.NET Web Form Designer.
//
InitializeComponent();
base.OnInit(e);
}

/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>

private void InitializeComponent() {
this.Load += new System.EventHandler(this.Page_Load);
}
#endregion

Nov 16 '05 #2
Thanks for your suggestion.

Anyhow, may I?:
Here too this paper is talking about the “phases in the lifecycle of a
control.” But I’m concerned with an .aspx page, not with a control possibly
contained in such a page. And I’m not at all convinced that it is the same
thing, or it is equivalent.

See you.
P.M.
"Ollie Riches" wrote:
this might help you

http://msdn.microsoft.com/library/de...us/cpguide/htm
l/cpconControlExecutionLifecycle.asp
--
HTH

Ollie Riches
http://www.phoneanalyser.net

Disclaimer: Opinions expressed in this forum are my own, and not
representative of my employer.
I do not answer questions on behalf of my employer. I'm just a programmer
helping programmers.

"Studio P.M." <St******@discussions.microsoft.com> wrote in message
news:D8**********************************@microsof t.com...
Dear colleagues,
I kindly ask the C# developers community to help me to REALLY

understand
the Page_Load event, so to REALLY have it under control.

Reason for this question is that I cannot anymore accept passively the
behavior of the "Web Form Designer" automatically generated code because

of
the fact that, in some circumstances (that I can reproduce at will), my

code
is victim of a Page_Load multiple "firing". In other words the Page_Load
event handler inexplicably enters more than once and, at the second entry,
Login credentials are asked again interactively. With disruptive effects

for
my current project.

Let me begin this discussion with what I certainly do not know, or I do

not
know for sure.
P1) I do not know what really triggers the OnInit event, beyond the fact
that it is overridden in the "Web Form Designer" automatically generated

code
(see hereafter).
P2) I do not know what really the original base.OnInit(e) at last will

do.
Indeed I've found documentation only about Control.OnInit, but I'm not
convinced it can apply to this case, where no server control in involved
(please see next point), and such an article, as the "ASP.NET Server

Control
Event Model", doesn't exactly apply. Does it?
P3) Consider that, by definition, "events associated with server controls
are raised on the client but handled on the Web server by the ASP.NET page
framework". Here the case of OnInit, of an .aspx Web page, is rather
different, isn't it? Indeed the OnInit event happens BEFORE the presence

of
the Web page on the client computer, indeed this is the very event of

posting
a page from the server to the client. And this event shouldn't happen

again
until I deliberately ask for another .aspx page. Shouldn't it? But, alas,

it
DOES happen, out of my control. And all that is precisely the reason of

this
call "To really understand the Page_Load event".

As you see I'm really confused (and baffled too.).
Thanks for your time.
P.M.

- - - - -=- - - - -=- - - - -=
"Web Form Designer" automatically generated code:

#region Web Form Designer generated code
override protected void OnInit(aS.EventArgs e) {
//
// CODEGEN: This call is required by the ASP.NET Web Form Designer.
//
InitializeComponent();
base.OnInit(e);
}

/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>

private void InitializeComponent() {
this.Load += new System.EventHandler(this.Page_Load);
}
#endregion


Nov 16 '05 #3
The order of events for a control and a page are the same. An aspx
(System.Web.UI.Page) is derived from System.Web.UI.Control.

Ollie
"Studio P.M." <St******@discussions.microsoft.com> wrote in message
news:C8**********************************@microsof t.com...
Thanks for your suggestion.

Anyhow, may I?:
Here too this paper is talking about the "phases in the lifecycle of a
control." But I'm concerned with an .aspx page, not with a control possibly contained in such a page. And I'm not at all convinced that it is the same
thing, or it is equivalent.

See you.
P.M.
"Ollie Riches" wrote:
this might help you

http://msdn.microsoft.com/library/de...us/cpguide/htm l/cpconControlExecutionLifecycle.asp
--
HTH

Ollie Riches
http://www.phoneanalyser.net

Disclaimer: Opinions expressed in this forum are my own, and not
representative of my employer.
I do not answer questions on behalf of my employer. I'm just a programmer helping programmers.

"Studio P.M." <St******@discussions.microsoft.com> wrote in message
news:D8**********************************@microsof t.com...
Dear colleagues,
I kindly ask the C# developers community to help me to REALLY

understand
the Page_Load event, so to REALLY have it under control.

Reason for this question is that I cannot anymore accept passively the
behavior of the "Web Form Designer" automatically generated code because
of
the fact that, in some circumstances (that I can reproduce at will),
my code
is victim of a Page_Load multiple "firing". In other words the
Page_Load event handler inexplicably enters more than once and, at the second entry, Login credentials are asked again interactively. With disruptive effects for
my current project.

Let me begin this discussion with what I certainly do not know, or I
do not
know for sure.
P1) I do not know what really triggers the OnInit event, beyond the
fact that it is overridden in the "Web Form Designer" automatically generated code
(see hereafter).
P2) I do not know what really the original base.OnInit(e) at last
will do.
Indeed I've found documentation only about Control.OnInit, but I'm not
convinced it can apply to this case, where no server control in
involved (please see next point), and such an article, as the "ASP.NET Server

Control
Event Model", doesn't exactly apply. Does it?
P3) Consider that, by definition, "events associated with server controls are raised on the client but handled on the Web server by the ASP.NET page framework". Here the case of OnInit, of an .aspx Web page, is rather
different, isn't it? Indeed the OnInit event happens BEFORE the

presence of
the Web page on the client computer, indeed this is the very event of

posting
a page from the server to the client. And this event shouldn't happen

again
until I deliberately ask for another .aspx page. Shouldn't it? But,
alas, it
DOES happen, out of my control. And all that is precisely the reason
of this
call "To really understand the Page_Load event".

As you see I'm really confused (and baffled too.).
Thanks for your time.
P.M.

- - - - -=- - - - -=- - - - -=
"Web Form Designer" automatically generated code:

#region Web Form Designer generated code
override protected void OnInit(aS.EventArgs e) {
//
// CODEGEN: This call is required by the ASP.NET Web Form Designer.
//
InitializeComponent();
base.OnInit(e);
}

/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>

private void InitializeComponent() {
this.Load += new System.EventHandler(this.Page_Load);
}
#endregion


Nov 16 '05 #4

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

Similar topics

13
2559
by: z. f. | last post by:
Hi, i have a class that is derived from System.Web.UI.Page, and this is the class i use in my application as PageBase. all other page classes are deriverd from my PageBase instead of the...
2
406
by: Guy Lafleur | last post by:
I have a user control that builds a treeview dynamically in the Page_Load event. Also, I have the AutoEventWireup property set to true (i.e., <%@ Control AutoEventWireup="true" %>). Then, when I...
0
1441
by: Dailan | last post by:
Hi, I create a tree view. Each node has link button associate with it, which includes add, edit, delete buttons. The way I did is for users who have very low capablity of using computer. Now I...
7
5223
by: Jibey | last post by:
Hello: I'm facing a very strange problem. When I run my Web application in Visual Studio.NET the Page_Load event is not executing. Other events like a Button_Click are executing. It doesn't...
4
3941
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...
4
1332
by: needin4mation | last post by:
I am inserting a row in a database. All that works fine. What I now need is the last inserted id from the database. I can get that. Again all working. Then what I need to have is that same...
12
17351
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,...
1
6921
by: puja | last post by:
hi all, I have this .aspx page for which the Page_load event occurs twice. I found out while debugging. After searching google, I tried checking with Page.Ispostback method and also had...
1
2947
by: rockdale | last post by:
Hi, I have a masterpage and on the page_load event I Populate my mainmenu from database. I the page_load event of my content, I am trying to programmly select the menuitem that represent...
0
7128
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
7169
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
7215
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
6892
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7385
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
3088
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1425
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
661
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
294
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.