multiple inheritance

E

Emmanuel

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,
 
M

Marina

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.
 
E

Emmanuel

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,
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,756
Messages
2,569,540
Members
45,024
Latest member
ARDU_PROgrammER

Latest Threads

Top