By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
448,497 Members | 1,295 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 448,497 IT Pros & Developers. It's quick & easy.

multiple inheritance

P: n/a
Hi,

I'm working on a c# web app and require having some code which runs in the
page Load event of each page and to be reusable in other web apps.

So i decided to use a Class Library which contains a class that inherits
from the System.Web.UI.Page. the class contains an override of the OnLoad
event in which the common code is executed.

However, i also need to have an intermediate level class which inherits from
this base page to perform web app specific logic. this is were my problem
lies. If i make the actual web forms to inherit from the Intermediate page
which is overriding the OnLoad of the base page, the Page_Load event of the
web forms will not be executed.

Actually, the OnLoad event of the base page does not get executed also, but
i fixed this by placing a base.OnLoad(e) line in the OnLoad of the
intermediate page.

How can i make the BasePage OnLoad, the IntermediatePage OnLoad and the web
form Page_Load events get fired in that order?

regards,
Nov 19 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
Sorry, I am really confused as to what you are asking here.

First off, 'multiple inheritance' typically refers to the ability to have
one class inherit from 2 or more other classes. Not to multi-level
inheritance hierarchy, which is what you are describing.

Secondly, I am confused as to what you are trying to accomplish or what
order you need things to fire in?

If every class overrides OnLoad, calls base.OnLoad first, and then does
whatever it needs to do, it will all be fine. If only the base class does
this and the child just handles the Load event, then the child's Load event
will fire first (since the OnLoad of the Page class raises this event), and
only then will the base class's custom code execute.

"Emmanuel" <em******@email.com> wrote in message
news:eG**************@TK2MSFTNGP11.phx.gbl...
Hi,

I'm working on a c# web app and require having some code which runs in the
page Load event of each page and to be reusable in other web apps.

So i decided to use a Class Library which contains a class that inherits
from the System.Web.UI.Page. the class contains an override of the OnLoad
event in which the common code is executed.

However, i also need to have an intermediate level class which inherits from this base page to perform web app specific logic. this is were my problem
lies. If i make the actual web forms to inherit from the Intermediate page
which is overriding the OnLoad of the base page, the Page_Load event of the web forms will not be executed.

Actually, the OnLoad event of the base page does not get executed also, but i fixed this by placing a base.OnLoad(e) line in the OnLoad of the
intermediate page.

How can i make the BasePage OnLoad, the IntermediatePage OnLoad and the web form Page_Load events get fired in that order?

regards,

Nov 19 '05 #2

P: n/a
Hi Marina,

yes, i meant to say multi-level inheritance. sorry about that.

The solution was so simple, and you brought me to it. Thanks a lot!

My problem was that the web form was not overriding the OnLoad method, but
was simply registering an event handler to the Load event.

regards,

"Marina" <so*****@nospam.com> wrote in message
news:uS**************@TK2MSFTNGP12.phx.gbl...
Sorry, I am really confused as to what you are asking here.

First off, 'multiple inheritance' typically refers to the ability to have
one class inherit from 2 or more other classes. Not to multi-level
inheritance hierarchy, which is what you are describing.

Secondly, I am confused as to what you are trying to accomplish or what
order you need things to fire in?

If every class overrides OnLoad, calls base.OnLoad first, and then does
whatever it needs to do, it will all be fine. If only the base class does
this and the child just handles the Load event, then the child's Load
event
will fire first (since the OnLoad of the Page class raises this event),
and
only then will the base class's custom code execute.

"Emmanuel" <em******@email.com> wrote in message
news:eG**************@TK2MSFTNGP11.phx.gbl...
Hi,

I'm working on a c# web app and require having some code which runs in
the
page Load event of each page and to be reusable in other web apps.

So i decided to use a Class Library which contains a class that inherits
from the System.Web.UI.Page. the class contains an override of the OnLoad
event in which the common code is executed.

However, i also need to have an intermediate level class which inherits

from
this base page to perform web app specific logic. this is were my problem
lies. If i make the actual web forms to inherit from the Intermediate
page
which is overriding the OnLoad of the base page, the Page_Load event of

the
web forms will not be executed.

Actually, the OnLoad event of the base page does not get executed also,

but
i fixed this by placing a base.OnLoad(e) line in the OnLoad of the
intermediate page.

How can i make the BasePage OnLoad, the IntermediatePage OnLoad and the

web
form Page_Load events get fired in that order?

regards,


Nov 19 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.