Inheritance of controls & pages

G

Guest

I'm developing a fairly large application in ASP.NET 2.0. In this
applicaiton, I have a combination of .aspx and .ascx pages and controls, each
of which has code-behind files which do my application logic to generate the
interface.

I would like to create a "master" class which would contain methods, etc
that can be accessed by all .aspx and controls within the application. What's
the best way to do this?

I've tried creating a new class that inherits from System.Web.UI.UserControl
and implements new methods, then inheriting from this class when I create new
user controls. This works awesome, because then in any user control, I can say

me.MyInheritedMethod();

But this does not help for Pages... I'd have to create a seperate class for
Pages to inherit from.

I feel like I understand inheritance well enough, but I can't seem to get my
head wrapped around the best way to accomplish it for both. Do I need to
create a new class that inherits from an interface?

Thanx
 
G

Guest

You could put common code in your Master Page.
Another approach is to make a static class and put it in the App_Code folder.
 

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

Top