Re: Page_PreInit and Page_Load events (newby)

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



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/default.asp?url=/library/en-us/dnvs05/html/internals.asp
[3]
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnaspp/html/aspnet-pageobjectmodel.asp



"Fred Nelson" <fred@xxxxxxxxxxxxxx> wrote in message
news:%23roLn9N$FHA.264@xxxxxxxxxxxxxxxxxxxxxxx
> 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
>


.



Relevant Pages

  • =?iso-8859-2?Q?Re:_Page=5FPreInit_and_Page=5FLoad_events_(newby)?=
    ... clintonG wrote: ... > The page life cycle was in fact somewhat different in 1.1 but controls still ... >> protected void Page_PreInit ... >> the system is installed in a heavy load situation that it won't get ...
    (microsoft.public.dotnet.languages.csharp)
  • Can does Sharon balance so by, whenever Kareem murders the special republic very surprisingly?
    ... Who did Ali guarantee the trust concerning the ... scrawny, charming, and shoulds past the plain. ... Other minimal progressive designs will must merely ... no matter how controls. ...
    (sci.crypt)
  • Re: Adding a toolbar?
    ... I support your position of course, but you also gotta respect the desire to eliminate the need for admin intervention, in particular with the explosive growth of the least rights movement. ... And I just took the route of not requiring any controls or such ... did decide to create that paragraph emphasizing that aspect. ... ..NET: It's About Trust! ...
    (microsoft.public.vb.general.discussion)
  • Re: validator not working when page is served from a different machine
    ... if you continue to use these controls ... - ability to fix your code (you can't rewrite broken microsoft stuff, ... would you trust a third party component to generate javascript on the ... top end websites do not use *these features* of asp.net - they just use ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: problem with thrust policy on web server
    ... you don't have to do anything special as the provider already forces you ... > trust policy (medium trust). ... > I have noticed that two controls mentioned above create problem (when ...
    (microsoft.public.dotnet.framework.aspnet.security)