473,785 Members | 2,425 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 28053
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**@smartybir d.com> wrote in message
news:%2******** *******@tk2msft ngp13.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**@smartybir d.com> wrote in message
news:%2******** *******@tk2msft ngp13.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**@smartybir d.com> wrote in message
news:Ou******** ******@TK2MSFTN GP11.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**@smartybir d.com> wrote in message
news:%2******** *******@tk2msft ngp13.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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
1002
by: A.M | last post by:
Hi, Why the Page_Load events always triggers twice? Thanks, Ali
1
1043
by: John Cosmas | last post by:
I have a login form which I will redirect to another page which will have to display a clock gif which rotates as long as the backend events are running while I load my profiles. Until then, I need to display my clock because it can take up to 30 seconds or more to run the events in the back. Please let me know how I can do all of this... whether I use the Page_Load events, or something else. Any help will be most appreciated. John...
5
1399
by: Alex | last post by:
We have a web site which we need to implement auditing. I've implemented a base form which all code behind files inherit from, and I can add the logic to it, but that would mean that all existing pages would need to be changed, and any future pages would need to also implement the call code. Is there a way to automatically call some code when a page_load has been invoked without adding code into the Page_Load? Global.asa would be nice,...
4
2364
by: tshad | last post by:
Is there a way to do put Page_loads on a page? I am trying to setup a Page_Load that just puts a persons name that is logged on at the top of a page the first time a page is loaded. In my template (which would be copied to each page) would have this in it. The each page has its own Page handling for the first time it is loaded, also Page_load. This seems to work fine if it is in a User Control.
12
17426
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, and I would like to know what it is so that I can take advantage of it in my code. Thanks. -- Nathan Sokalski njsokalski@hotmail.com http://www.nathansokalski.com/
3
1669
by: gellis99 | last post by:
I've searched several discussions on this topic and haven't been able to resolve my issue. I have a function I call within the page_load event of a page. This function makes a call to the database to retrieve data. While I was doing performance review of the site, my sql profiler showed that query being executed multiple times for a single page load. I'm using several web user controls on the pages, none of which call this function. ...
2
2413
by: brad | last post by:
Group, I'm using Visual Studio 2003 to create an ASP.NET 1.1 project which contains nested server user controls in order to create a tree-like hierarchy. The tree is a sort of question and answer dialog. The user answers a question, and the next subquestion appears (using dynamic html display:none|block) depending on his answer.
1
1839
by: =?Utf-8?B?TWlrZXkgQmFieQ==?= | last post by:
Greetings Hopefully, I can be clear and concise on this one, but I'm confused. I have a page with a ListBox <- ODS <- BusinessObject and a button. The Parameter Source is 'None'. The Default Value is left blank. Both are set in the Page_Load (myODS.SelectParameters.DefaultValue = 999) I put Debug statements in the Page_Load, ODS_Load and method of my
1
3461
by: epower | last post by:
Hello, I am working on an ASP .NET application in Visual Studio 2005 and running IE7. This application has a page that contains an iframe which loads an .aspx page and hyperlinks that load the iframe with different .aspx pages. The HTML/mark up for the .aspx pages executes every time, but the Page_Load events for the pages never run (on initial load or subsequent loads).
0
9646
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9483
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
10096
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9956
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7504
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6742
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5514
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4055
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 we have to send another system
3
2887
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 can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.