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

Inheritance of controls & pages

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
Jan 12 '06 #1
1 986
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.

--
I hope this helps,
Steve C. Orr
MCSD, MVP
http://Steve.Orr.net

"Ryan" wrote:
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

Jan 13 '06 #2

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

Similar topics

5
by: Jukka K. Korpela | last post by:
The HTML specifications define the entities ‍, ‌, ‎, ‏ as denoting zero-width joiner, zero-width non-joiner, left to right mark, and right to left mark. Is there any evidence of...
1
by: George Durzi | last post by:
I'm converting a c# web application to support page inheritance so that I can really change the look and feel of my application by only modifying the ..cs that my pages inherit from. The only...
0
by: Dan | last post by:
I posted a similar post regarding problems with VS.NET design mode. I fixed that problem (with much thanks to this newsgroup) but now I have a second problem. I have created a class called...
5
by: Invalidlastname | last post by:
Hi, I just read the pattern "Design and Implementation Guidelines for Web Clients" from MSDN. Here is my question. In chapter 3,...
4
by: John Holmes | last post by:
With ASP we have setup a pretty good method for maintaining a consistent look and feel with minimal effort. The method has it's pros and cons, but the maintenance is minimal. The method consists of...
6
by: VR | last post by:
Hi, I read about Master Pages in ASP.Net 2.0 and after implementing some WinForms Visual Inheritance I tryed it with WebForms (let's say .aspx pages, my MasterPage does not have a form tag itself...
13
by: Ranginald | last post by:
I am new to oop so please bear with me: Could someone please explain to me why the "protected void runCategory() method" cannot access the local ddlCategory object that is easily accessed in...
4
by: Joe | last post by:
We are working on a project that requires 3rd parties (ie, consultants) to use our ASP.net webforms in a very reusable manner. The big catch is that we are not allowed to give them source. There...
1
by: =?Utf-8?B?Unlhbg==?= | last post by:
Hi, We use class extend parent class for cs file inheritance. Is this same concept for page - mater page ? And how we implement inheritance for user controls? If I need add some common...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.