473,320 Members | 1,982 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,320 software developers and data experts.

order of execution of page_load in a base and derived classes

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 original
System.Web.UI.Page in order to have common checks in the page base.

i make securirty checks in the page base page_load event.
if the security fails, i can do whatever i want before the "real" / derived
page gets to be executed.

but i have noticed that the derived page load event gets to be called before
the base page load event.

so i have a problem.

i can cancel the use of page_load in my derived pages, but i use this
function to check on PostBack events that does not have server (like button)
event handler, but there when will i move it to?

is this the correct execution order - the derived gets to called before the
base?

is this also the order of execution in inheritence or only with delegated
event handlers? ( i mean when you use the syntax of Page.onLoad +=
this_onLoad )....

TIA, z.
Nov 18 '05 #1
13 1659
Hi,

I have never been in this situation, but the first thing I would try is in
the Form.OnInit move the base.OnInit to the start of the method, before
register the Load handler for the current page.

cheers,

--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation

"z. f." <zi**@info-scopeREMSPAM.co.il> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...
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 original System.Web.UI.Page in order to have common checks in the page base.

i make securirty checks in the page base page_load event.
if the security fails, i can do whatever i want before the "real" / derived page gets to be executed.

but i have noticed that the derived page load event gets to be called before the base page load event.

so i have a problem.

i can cancel the use of page_load in my derived pages, but i use this
function to check on PostBack events that does not have server (like button) event handler, but there when will i move it to?

is this the correct execution order - the derived gets to called before the base?

is this also the order of execution in inheritence or only with delegated
event handlers? ( i mean when you use the syntax of Page.onLoad +=
this_onLoad )....

TIA, z.

Nov 18 '05 #2
Please don't cross-post.

I'm assuming you are using C# 'cuz you wouldn't have this behaviour in
VB....anyways, the simplest solution is to go into your derived page's
OnInit function in the "Web Form Designer generated code" region, and change
the order of the two executions:

InitializeComponent();
base.OnInit(e);

to

base.OnInit(e);
InitializeComponent();

This will cause the base page's init to load first, which will cause it's
Load event to get hooked up first, thus causing it to fire first.

Karl

"z. f." <zi**@info-scopeREMSPAM.co.il> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...
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 original System.Web.UI.Page in order to have common checks in the page base.

i make securirty checks in the page base page_load event.
if the security fails, i can do whatever i want before the "real" / derived page gets to be executed.

but i have noticed that the derived page load event gets to be called before the base page load event.

so i have a problem.

i can cancel the use of page_load in my derived pages, but i use this
function to check on PostBack events that does not have server (like button) event handler, but there when will i move it to?

is this the correct execution order - the derived gets to called before the base?

is this also the order of execution in inheritence or only with delegated
event handlers? ( i mean when you use the syntax of Page.onLoad +=
this_onLoad )....

TIA, z.

Nov 18 '05 #3
Hi again

I'm not very sure that the previous answer will solve the problem, IIRC
the order of execution of the handlers is not defined. therefore even ify ou
register first the parent you may get the derived executing first after all.

Therefore you have to use another approach, you could use a virtual method
that you call in the OnLoad event, so each class Page) define what needs to
be checked , being the trick to verify the parent first to have the first
line calling the parent method:
protected override Check()
{
parent.Check();
//do the checking
}

I think this will solve your problem.
Cheers,

--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation

"z. f." <zi**@info-scopeREMSPAM.co.il> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...
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 original System.Web.UI.Page in order to have common checks in the page base.

i make securirty checks in the page base page_load event.
if the security fails, i can do whatever i want before the "real" / derived page gets to be executed.

but i have noticed that the derived page load event gets to be called before the base page load event.

so i have a problem.

i can cancel the use of page_load in my derived pages, but i use this
function to check on PostBack events that does not have server (like button) event handler, but there when will i move it to?

is this the correct execution order - the derived gets to called before the base?

is this also the order of execution in inheritence or only with delegated
event handlers? ( i mean when you use the syntax of Page.onLoad +=
this_onLoad )....

TIA, z.

Nov 18 '05 #4
i use vb.net
and i don't override the OnInit method in my PageBase.

"Karl" <karl REMOVE @ REMOVE openmymind REMOVEMETOO . ANDME net> wrote in
message news:uP**************@TK2MSFTNGP09.phx.gbl...
Please don't cross-post.

I'm assuming you are using C# 'cuz you wouldn't have this behaviour in
VB....anyways, the simplest solution is to go into your derived page's
OnInit function in the "Web Form Designer generated code" region, and change the order of the two executions:

InitializeComponent();
base.OnInit(e);

to

base.OnInit(e);
InitializeComponent();

This will cause the base page's init to load first, which will cause it's
Load event to get hooked up first, thus causing it to fire first.

Karl

"z. f." <zi**@info-scopeREMSPAM.co.il> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...
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

original
System.Web.UI.Page in order to have common checks in the page base.

i make securirty checks in the page base page_load event.
if the security fails, i can do whatever i want before the "real" /

derived
page gets to be executed.

but i have noticed that the derived page load event gets to be called

before
the base page load event.

so i have a problem.

i can cancel the use of page_load in my derived pages, but i use this
function to check on PostBack events that does not have server (like

button)
event handler, but there when will i move it to?

is this the correct execution order - the derived gets to called before

the
base?

is this also the order of execution in inheritence or only with delegated event handlers? ( i mean when you use the syntax of Page.onLoad +=
this_onLoad )....

TIA, z.


Nov 18 '05 #5
i wouldn't like to add code to each page-class i add.
the idea behind using a PageBase is to not change the way i write the other
pages, just let them use the services the PageBase implement without even
"knowing" anout it.
"Ignacio Machin ( .NET/ C# MVP )" <ignacio.machin AT dot.state.fl.us> wrote
in message news:%2****************@tk2msftngp13.phx.gbl...
Hi again

I'm not very sure that the previous answer will solve the problem, IIRC
the order of execution of the handlers is not defined. therefore even ify ou register first the parent you may get the derived executing first after all.
Therefore you have to use another approach, you could use a virtual method that you call in the OnLoad event, so each class Page) define what needs to be checked , being the trick to verify the parent first to have the first
line calling the parent method:
protected override Check()
{
parent.Check();
//do the checking
}

I think this will solve your problem.
Cheers,

--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation

"z. f." <zi**@info-scopeREMSPAM.co.il> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...
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

original
System.Web.UI.Page in order to have common checks in the page base.

i make securirty checks in the page base page_load event.
if the security fails, i can do whatever i want before the "real" /

derived
page gets to be executed.

but i have noticed that the derived page load event gets to be called

before
the base page load event.

so i have a problem.

i can cancel the use of page_load in my derived pages, but i use this
function to check on PostBack events that does not have server (like

button)
event handler, but there when will i move it to?

is this the correct execution order - the derived gets to called before

the
base?

is this also the order of execution in inheritence or only with delegated event handlers? ( i mean when you use the syntax of Page.onLoad +=
this_onLoad )....

TIA, z.


Nov 18 '05 #6
We had the same problem with the Page_Load Event.

We solved it similar to the way Ignacio Machin describes using the OnLoad
event.

Good luck,

Benjamin Schwitter

"Ignacio Machin ( .NET/ C# MVP )" <ignacio.machin AT dot.state.fl.us> wrote
in message news:#n**************@tk2msftngp13.phx.gbl...
Hi again

I'm not very sure that the previous answer will solve the problem, IIRC
the order of execution of the handlers is not defined. therefore even ify ou register first the parent you may get the derived executing first after all.
Therefore you have to use another approach, you could use a virtual method that you call in the OnLoad event, so each class Page) define what needs to be checked , being the trick to verify the parent first to have the first
line calling the parent method:
protected override Check()
{
parent.Check();
//do the checking
}

I think this will solve your problem.
Cheers,

--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation

"z. f." <zi**@info-scopeREMSPAM.co.il> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...
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

original
System.Web.UI.Page in order to have common checks in the page base.

i make securirty checks in the page base page_load event.
if the security fails, i can do whatever i want before the "real" /

derived
page gets to be executed.

but i have noticed that the derived page load event gets to be called

before
the base page load event.

so i have a problem.

i can cancel the use of page_load in my derived pages, but i use this
function to check on PostBack events that does not have server (like

button)
event handler, but there when will i move it to?

is this the correct execution order - the derived gets to called before

the
base?

is this also the order of execution in inheritence or only with delegated event handlers? ( i mean when you use the syntax of Page.onLoad +=
this_onLoad )....

TIA, z.


Nov 18 '05 #7
also

from the IL created by VB compiler you see that in the constructor it is
adding the event handler:

Public Sub New()
AddHandler MyBase.Load, New EventHandler(AddressOf Me.Page_Load)
End Sub

"Karl" <karl REMOVE @ REMOVE openmymind REMOVEMETOO . ANDME net> wrote in
message news:uP**************@TK2MSFTNGP09.phx.gbl...
Please don't cross-post.

I'm assuming you are using C# 'cuz you wouldn't have this behaviour in
VB....anyways, the simplest solution is to go into your derived page's
OnInit function in the "Web Form Designer generated code" region, and change the order of the two executions:

InitializeComponent();
base.OnInit(e);

to

base.OnInit(e);
InitializeComponent();

This will cause the base page's init to load first, which will cause it's
Load event to get hooked up first, thus causing it to fire first.

Karl

"z. f." <zi**@info-scopeREMSPAM.co.il> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...
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

original
System.Web.UI.Page in order to have common checks in the page base.

i make securirty checks in the page base page_load event.
if the security fails, i can do whatever i want before the "real" /

derived
page gets to be executed.

but i have noticed that the derived page load event gets to be called

before
the base page load event.

so i have a problem.

i can cancel the use of page_load in my derived pages, but i use this
function to check on PostBack events that does not have server (like

button)
event handler, but there when will i move it to?

is this the correct execution order - the derived gets to called before

the
base?

is this also the order of execution in inheritence or only with delegated event handlers? ( i mean when you use the syntax of Page.onLoad +=
this_onLoad )....

TIA, z.


Nov 18 '05 #8
Can you show me some code? If I do this:

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
Trace.Write("derived load")
end sub

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
Trace.Write("baseload")
end sub

the base load always fires first.

Karl

"z. f." <zi**@info-scopeREMSPAM.co.il> wrote in message
news:%2***************@TK2MSFTNGP09.phx.gbl...
i use vb.net
and i don't override the OnInit method in my PageBase.

"Karl" <karl REMOVE @ REMOVE openmymind REMOVEMETOO . ANDME net> wrote in
message news:uP**************@TK2MSFTNGP09.phx.gbl...
Please don't cross-post.

I'm assuming you are using C# 'cuz you wouldn't have this behaviour in
VB....anyways, the simplest solution is to go into your derived page's
OnInit function in the "Web Form Designer generated code" region, and

change
the order of the two executions:

InitializeComponent();
base.OnInit(e);

to

base.OnInit(e);
InitializeComponent();

This will cause the base page's init to load first, which will cause it's
Load event to get hooked up first, thus causing it to fire first.

Karl

"z. f." <zi**@info-scopeREMSPAM.co.il> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...
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

original
System.Web.UI.Page in order to have common checks in the page base.

i make securirty checks in the page base page_load event.
if the security fails, i can do whatever i want before the "real" /

derived
page gets to be executed.

but i have noticed that the derived page load event gets to be called

before
the base page load event.

so i have a problem.

i can cancel the use of page_load in my derived pages, but i use this
function to check on PostBack events that does not have server (like

button)
event handler, but there when will i move it to?

is this the correct execution order - the derived gets to called
before the
base?

is this also the order of execution in inheritence or only with

delegated event handlers? ( i mean when you use the syntax of Page.onLoad +=
this_onLoad )....

TIA, z.



Nov 18 '05 #9
Hi,

IIRC the Page_Load is added in the OnInit handler:

override protected void OnInit(EventArgs e)
{
InitializeComponent();
base.OnInit(e);
}
private void InitializeComponent()
{
this.Load += new System.EventHandler(this.Page_Load);
}

Cheers,

--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation

"z. f." <zi**@info-scopeREMSPAM.co.il> wrote in message
news:eF**************@TK2MSFTNGP15.phx.gbl...
also

from the IL created by VB compiler you see that in the constructor it is
adding the event handler:

Public Sub New()
AddHandler MyBase.Load, New EventHandler(AddressOf Me.Page_Load)
End Sub

"Karl" <karl REMOVE @ REMOVE openmymind REMOVEMETOO . ANDME net> wrote in
message news:uP**************@TK2MSFTNGP09.phx.gbl...
Please don't cross-post.

I'm assuming you are using C# 'cuz you wouldn't have this behaviour in
VB....anyways, the simplest solution is to go into your derived page's
OnInit function in the "Web Form Designer generated code" region, and

change
the order of the two executions:

InitializeComponent();
base.OnInit(e);

to

base.OnInit(e);
InitializeComponent();

This will cause the base page's init to load first, which will cause it's
Load event to get hooked up first, thus causing it to fire first.

Karl

"z. f." <zi**@info-scopeREMSPAM.co.il> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...
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

original
System.Web.UI.Page in order to have common checks in the page base.

i make securirty checks in the page base page_load event.
if the security fails, i can do whatever i want before the "real" /

derived
page gets to be executed.

but i have noticed that the derived page load event gets to be called

before
the base page load event.

so i have a problem.

i can cancel the use of page_load in my derived pages, but i use this
function to check on PostBack events that does not have server (like

button)
event handler, but there when will i move it to?

is this the correct execution order - the derived gets to called
before the
base?

is this also the order of execution in inheritence or only with

delegated event handlers? ( i mean when you use the syntax of Page.onLoad +=
this_onLoad )....

TIA, z.



Nov 18 '05 #10
Hi,

You add it where you need it. each page's method should be responsible to
handle the functionalities implemented on it. All you have to do is call the
method in the Page_Load.

Why is that not ok with you?

cheers,

--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation
"z. f." <zi**@info-scopeREMSPAM.co.il> wrote in message
news:es**************@TK2MSFTNGP15.phx.gbl...
i wouldn't like to add code to each page-class i add.
the idea behind using a PageBase is to not change the way i write the other pages, just let them use the services the PageBase implement without even
"knowing" anout it.
"Ignacio Machin ( .NET/ C# MVP )" <ignacio.machin AT dot.state.fl.us> wrote in message news:%2****************@tk2msftngp13.phx.gbl...
Hi again

I'm not very sure that the previous answer will solve the problem, IIRC
the order of execution of the handlers is not defined. therefore even ify
ou
register first the parent you may get the derived executing first after

all.

Therefore you have to use another approach, you could use a virtual

method
that you call in the OnLoad event, so each class Page) define what needs

to
be checked , being the trick to verify the parent first to have the

first line calling the parent method:
protected override Check()
{
parent.Check();
//do the checking
}

I think this will solve your problem.
Cheers,

--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation

"z. f." <zi**@info-scopeREMSPAM.co.il> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...
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

original
System.Web.UI.Page in order to have common checks in the page base.

i make securirty checks in the page base page_load event.
if the security fails, i can do whatever i want before the "real" /

derived
page gets to be executed.

but i have noticed that the derived page load event gets to be called

before
the base page load event.

so i have a problem.

i can cancel the use of page_load in my derived pages, but i use this
function to check on PostBack events that does not have server (like

button)
event handler, but there when will i move it to?

is this the correct execution order - the derived gets to called
before the
base?

is this also the order of execution in inheritence or only with

delegated event handlers? ( i mean when you use the syntax of Page.onLoad +=
this_onLoad )....

TIA, z.



Nov 18 '05 #11
you mean in c# don't you?
it is no question, it's a fact VB does it the way i showed, you can't
control it.

"Ignacio Machin ( .NET/ C# MVP )" <ignacio.machin AT dot.state.fl.us> wrote
in message news:ux**************@tk2msftngp13.phx.gbl...
Hi,

IIRC the Page_Load is added in the OnInit handler:

override protected void OnInit(EventArgs e)
{
InitializeComponent();
base.OnInit(e);
}
private void InitializeComponent()
{
this.Load += new System.EventHandler(this.Page_Load);
}

Cheers,

--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation

"z. f." <zi**@info-scopeREMSPAM.co.il> wrote in message
news:eF**************@TK2MSFTNGP15.phx.gbl...
also

from the IL created by VB compiler you see that in the constructor it is
adding the event handler:

Public Sub New()
AddHandler MyBase.Load, New EventHandler(AddressOf Me.Page_Load)
End Sub

"Karl" <karl REMOVE @ REMOVE openmymind REMOVEMETOO . ANDME net> wrote in
message news:uP**************@TK2MSFTNGP09.phx.gbl...
Please don't cross-post.

I'm assuming you are using C# 'cuz you wouldn't have this behaviour in
VB....anyways, the simplest solution is to go into your derived page's
OnInit function in the "Web Form Designer generated code" region, and

change
the order of the two executions:

InitializeComponent();
base.OnInit(e);

to

base.OnInit(e);
InitializeComponent();

This will cause the base page's init to load first, which will cause

it's Load event to get hooked up first, thus causing it to fire first.

Karl

"z. f." <zi**@info-scopeREMSPAM.co.il> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...
> 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
original
> System.Web.UI.Page in order to have common checks in the page base.
>
> i make securirty checks in the page base page_load event.
> if the security fails, i can do whatever i want before the "real" /
derived
> page gets to be executed.
>
> but i have noticed that the derived page load event gets to be called before
> the base page load event.
>
> so i have a problem.
>
> i can cancel the use of page_load in my derived pages, but i use this > function to check on PostBack events that does not have server (like
button)
> event handler, but there when will i move it to?
>
> is this the correct execution order - the derived gets to called before the
> base?
>
> is this also the order of execution in inheritence or only with

delegated
> event handlers? ( i mean when you use the syntax of Page.onLoad +=
> this_onLoad )....
>
> TIA, z.
>
>



Nov 18 '05 #12
"z. f." <zi**@info-scopeREMSPAM.co.il> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...
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 original System.Web.UI.Page in order to have common checks in the page base.

i make securirty checks in the page base page_load event.
if the security fails, i can do whatever i want before the "real" / derived page gets to be executed.

but i have noticed that the derived page load event gets to be called before the base page load event.

so i have a problem.

i can cancel the use of page_load in my derived pages, but i use this
function to check on PostBack events that does not have server (like button) event handler, but there when will i move it to?

is this the correct execution order - the derived gets to called before the base?

is this also the order of execution in inheritence or only with delegated
event handlers? ( i mean when you use the syntax of Page.onLoad +=
this_onLoad )....

TIA, z.


Your classes dont work the way you would like. The ASPNET engine works with
your derived classes & calls the overriding methods in them, it couldn't
care about base classes ( I suppose it has to be System.Web.UI.Page
eventually) .
The effect you want only happens with new() where the 1st line in the
suboutine is either a call to one of the base classes constructors or an
implicit call to its parameterless constructor. So if you can put your
initialisation in the base classes new() then it should be fixed. However I
dont think all the ASP features are ready at that time, I also dont know if
any page object is reused for subsequent requests which could possibly lead
to some speedup but probably lead to hours of extra debugging. Maybe that
could be added by use of an attribute ?

--
Jonathan Bailey.
Nov 18 '05 #13
Hi,

Yes, the code I shown was in C#, I havent worked at all with VB but this is
the code the designer created :

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

I don;t know much about how the event is hooked , but I can bet it's done
in the constructor as you said.

Again the virtual method approach can help you in this escenario.

cheers,
--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation

"z. f." <zi**@info-scopeREMSPAM.co.il> wrote in message
news:O7**************@TK2MSFTNGP12.phx.gbl...
you mean in c# don't you?
it is no question, it's a fact VB does it the way i showed, you can't
control it.

"Ignacio Machin ( .NET/ C# MVP )" <ignacio.machin AT dot.state.fl.us> wrote in message news:ux**************@tk2msftngp13.phx.gbl...
Hi,

IIRC the Page_Load is added in the OnInit handler:

override protected void OnInit(EventArgs e)
{
InitializeComponent();
base.OnInit(e);
}
private void InitializeComponent()
{
this.Load += new System.EventHandler(this.Page_Load);
}

Cheers,

--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation

"z. f." <zi**@info-scopeREMSPAM.co.il> wrote in message
news:eF**************@TK2MSFTNGP15.phx.gbl...
also

from the IL created by VB compiler you see that in the constructor it is adding the event handler:

Public Sub New()
AddHandler MyBase.Load, New EventHandler(AddressOf Me.Page_Load)
End Sub

"Karl" <karl REMOVE @ REMOVE openmymind REMOVEMETOO . ANDME net> wrote in message news:uP**************@TK2MSFTNGP09.phx.gbl...
> Please don't cross-post.
>
> I'm assuming you are using C# 'cuz you wouldn't have this behaviour in > VB....anyways, the simplest solution is to go into your derived page's > OnInit function in the "Web Form Designer generated code" region, and change
> the order of the two executions:
>
> InitializeComponent();
> base.OnInit(e);
>
> to
>
> base.OnInit(e);
> InitializeComponent();
>
> This will cause the base page's init to load first, which will cause

it's
> Load event to get hooked up first, thus causing it to fire first.
>
> Karl
>
> "z. f." <zi**@info-scopeREMSPAM.co.il> wrote in message
> news:%2****************@TK2MSFTNGP10.phx.gbl...
> > 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 > original
> > System.Web.UI.Page in order to have common checks in the page base. > >
> > i make securirty checks in the page base page_load event.
> > if the security fails, i can do whatever i want before the "real" / > derived
> > page gets to be executed.
> >
> > but i have noticed that the derived page load event gets to be

called > before
> > the base page load event.
> >
> > so i have a problem.
> >
> > i can cancel the use of page_load in my derived pages, but i use this > > function to check on PostBack events that does not have server (like > button)
> > event handler, but there when will i move it to?
> >
> > is this the correct execution order - the derived gets to called

before
> the
> > base?
> >
> > is this also the order of execution in inheritence or only with
delegated
> > event handlers? ( i mean when you use the syntax of Page.onLoad +=
> > this_onLoad )....
> >
> > TIA, z.
> >
> >
>
>



Nov 18 '05 #14

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

Similar topics

1
by: Mike | last post by:
I seem to be having a problem with the way destructors are called with derived classes. Below is a short example of what I'm trying to do. In the example a is the base class. It has a function...
1
by: Steven T. Hatton | last post by:
I started working on something I had failed to understand several months ago. The original discussion on c.l.c++-m has this message ID: news://Message-ID:...
5
by: Nathan Bullock | last post by:
Hi, I have a base class, say Base and there are two classes, say Class1 and Class2 which are derived from Base. Is there any way for me, say from a static method in Base, to get a list of all...
13
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...
6
by: John Glover | last post by:
I'm having a very strange problem with XML serialization. I'm writing web services which pass instances of various classes back and forth as parameters and return values of web methods. The...
8
by: Manuel | last post by:
Hi! If I've a vector filled with abstract classes, can I push in it the derived classes too? Even if derived classes have new methods? I've done some experiments, and it seem I can push the...
6
by: ivan.leben | last post by:
I want to write a Mesh class using half-edges. This class uses three other classes: Vertex, HalfEdge and Face. These classes should be linked properly in the process of building up the mesh by...
26
by: nyathancha | last post by:
Hi, How Do I create an instance of a derived class from an instance of a base class, essentially wrapping up an existing base class with some additional functionality. The reason I need this is...
15
by: Bob Johnson | last post by:
I have a base class that must have a member variable populated by, and only by, derived classes. It appears that if I declare the variable as "internal protected" then the base class *can*...
0
by: John Grandy | last post by:
If I have UserControlDervied that derives from another UserControlBase , and in UserControlBase the OnLoad method is overriden , is it necessary to also override the OnLoad method in...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.