469,306 Members | 1,958 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,306 developers. It's quick & easy.

Page_PreInit and Page_Load events (newby)

Hi Folks:

I have a question about the Page_PreInit and Page_Load events in a web
application.

My question is: can I count on the Page_PreInit having completed before
the Page_Load event starts. (I recall that someone told me in VS2003
that you could not count it!)

I'm using C#.NET 2005 so if that was an issue in 2003, is it still an
issue?

I will be updating a static class in the Page_PreInit and using it in
the Page_Load so it will be important that the sequence is followed.

For example (using just an integer):

public static int myIntValue;

protected void Page_PreInit(..)
{
myIntValue = 1;
}

protected void Page_Load(..)
{
if (myIntValue == 1) ... etc.
}
Everything works fine in the "lab" however I want to be sure that when
the system is installed in a heavy load situation that it won't get
lost!

Also, if it is an issue and I test for a null value in Page_Load then
what would I do to continue to allow the page to load?

Thanks very much for your help!

Fred

Dec 9 '05 #1
3 27869
Always trust the official documentation [1-3]
Trust but always verify what you hear in the newsgroups.

The page life cycle was in fact somewhat different in 1.1 but controls still
have to be Init(ialized) by the Page class somehow. Its academic now that
2.0 is released and 2.0 is where you need to focus unless you intend to use
1.1 or support 1.1 applications.

In 2.0 the Page_Init event is always processed before the Page_Load event
whether you have code in the event or not as it is how all controls in the
page are Init(ialized) before the control tree is constructed.

As for your question about a test I would use the following in the Page_Load
event...

if(myIntValue != null)
{ // whatever }

<%= Clinton Gallagher
METROmilwaukee (sm) "A Regional Information Service"
NET csgallagher AT metromilwaukee.com
URL http://metromilwaukee.com/
URL http://clintongallagher.metromilwaukee.com/

[1] http://msdn2.microsoft.com/en-us/library/ms178472.aspx
[2]
http://msdn.microsoft.com/library/de.../internals.asp
[3]
http://msdn.microsoft.com/library/de...bjectmodel.asp

"Fred Nelson" <fr**@smartybird.com> wrote in message
news:%2***************@tk2msftngp13.phx.gbl...
Hi Folks:

I have a question about the Page_PreInit and Page_Load events in a web
application.

My question is: can I count on the Page_PreInit having completed before
the Page_Load event starts. (I recall that someone told me in VS2003
that you could not count it!)

I'm using C#.NET 2005 so if that was an issue in 2003, is it still an
issue?

I will be updating a static class in the Page_PreInit and using it in
the Page_Load so it will be important that the sequence is followed.

For example (using just an integer):

public static int myIntValue;

protected void Page_PreInit(..)
{
myIntValue = 1;
}

protected void Page_Load(..)
{
if (myIntValue == 1) ... etc.
}
Everything works fine in the "lab" however I want to be sure that when
the system is installed in a heavy load situation that it won't get
lost!

Also, if it is an issue and I test for a null value in Page_Load then
what would I do to continue to allow the page to load?

Thanks very much for your help!

Fred

Dec 9 '05 #2
Clinton:

Thanks very much for your help!

Fortunatley this new project will be entirely 2.0!

Fred

clintonG wrote:
Always trust the official documentation [1-3]
Trust but always verify what you hear in the newsgroups.

The page life cycle was in fact somewhat different in 1.1 but controls still
have to be Init(ialized) by the Page class somehow. Its academic now that
2.0 is released and 2.0 is where you need to focus unless you intend to use
1.1 or support 1.1 applications.

In 2.0 the Page_Init event is always processed before the Page_Load event
whether you have code in the event or not as it is how all controls in the
page are Init(ialized) before the control tree is constructed.

As for your question about a test I would use the following in the Page_Load
event...

if(myIntValue != null)
{ // whatever }

<%= Clinton Gallagher
METROmilwaukee (sm) "A Regional Information Service"
NET csgallagher AT metromilwaukee.com
URL http://metromilwaukee.com/
URL http://clintongallagher.metromilwaukee.com/

[1] http://msdn2.microsoft.com/en-us/library/ms178472.aspx
[2]
http://msdn.microsoft.com/library/de.../internals.asp
[3]
http://msdn.microsoft.com/library/de...bjectmodel.asp

"Fred Nelson" <fr**@smartybird.com> wrote in message
news:%2***************@tk2msftngp13.phx.gbl...
Hi Folks:

I have a question about the Page_PreInit and Page_Load events in a web
application.

My question is: can I count on the Page_PreInit having completed before
the Page_Load event starts. (I recall that someone told me in VS2003
that you could not count it!)

I'm using C#.NET 2005 so if that was an issue in 2003, is it still an
issue?

I will be updating a static class in the Page_PreInit and using it in
the Page_Load so it will be important that the sequence is followed.

For example (using just an integer):

public static int myIntValue;

protected void Page_PreInit(..)
{
myIntValue = 1;
}

protected void Page_Load(..)
{
if (myIntValue == 1) ... etc.
}
Everything works fine in the "lab" however I want to be sure that when
the system is installed in a heavy load situation that it won't get
lost!

Also, if it is an issue and I test for a null value in Page_Load then
what would I do to continue to allow the page to load?

Thanks very much for your help!

Fred



Dec 10 '05 #3
Pay it forward :-)

<%= Clinton Gallagher

"Fred Nelson" <fr**@smartybird.com> wrote in message
news:Ou**************@TK2MSFTNGP11.phx.gbl...
Clinton:

Thanks very much for your help!

Fortunatley this new project will be entirely 2.0!

Fred

clintonG wrote:
Always trust the official documentation [1-3]
Trust but always verify what you hear in the newsgroups.

The page life cycle was in fact somewhat different in 1.1 but controls
still
have to be Init(ialized) by the Page class somehow. Its academic now that
2.0 is released and 2.0 is where you need to focus unless you intend to
use
1.1 or support 1.1 applications.

In 2.0 the Page_Init event is always processed before the Page_Load event
whether you have code in the event or not as it is how all controls in
the
page are Init(ialized) before the control tree is constructed.

As for your question about a test I would use the following in the
Page_Load
event...

if(myIntValue != null)
{ // whatever }

<%= Clinton Gallagher
METROmilwaukee (sm) "A Regional Information Service"
NET csgallagher AT metromilwaukee.com
URL http://metromilwaukee.com/
URL http://clintongallagher.metromilwaukee.com/

[1] http://msdn2.microsoft.com/en-us/library/ms178472.aspx
[2]
http://msdn.microsoft.com/library/de.../internals.asp
[3]
http://msdn.microsoft.com/library/de...bjectmodel.asp

"Fred Nelson" <fr**@smartybird.com> wrote in message
news:%2***************@tk2msftngp13.phx.gbl...
> Hi Folks:
>
> I have a question about the Page_PreInit and Page_Load events in a web
> application.
>
> My question is: can I count on the Page_PreInit having completed before
> the Page_Load event starts. (I recall that someone told me in VS2003
> that you could not count it!)
>
> I'm using C#.NET 2005 so if that was an issue in 2003, is it still an
> issue?
>
> I will be updating a static class in the Page_PreInit and using it in
> the Page_Load so it will be important that the sequence is followed.
>
> For example (using just an integer):
>
> public static int myIntValue;
>
> protected void Page_PreInit(..)
> {
> myIntValue = 1;
> }
>
> protected void Page_Load(..)
> {
> if (myIntValue == 1) ... etc.
> }
>
>
> Everything works fine in the "lab" however I want to be sure that when
> the system is installed in a heavy load situation that it won't get
> lost!
>
> Also, if it is an issue and I test for a null value in Page_Load then
> what would I do to continue to allow the page to load?
>
> Thanks very much for your help!
>
> Fred
>


Dec 10 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

6 posts views Thread by A.M | last post: by
1 post views Thread by John Cosmas | last post: by
5 posts views Thread by Alex | last post: by
4 posts views Thread by tshad | last post: by
12 posts views Thread by Nathan Sokalski | last post: by
3 posts views Thread by gellis99 | last post: by
1 post views Thread by =?Utf-8?B?TWlrZXkgQmFieQ==?= | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by suresh191 | last post: by
reply views Thread by harlem98 | last post: by
1 post views Thread by Geralt96 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.