473,326 Members | 2,126 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,326 software developers and data experts.

Code reuse, code behind, and can't inherit since already inheritsPage

I've noticed that C# can only inherit from a single class. At the same time, the
CodeBehind in an aspx.cs file inherits from Page.

So what do you all do to reuse code in .aspx.cs classes?

Seems to me one has to create classes and make them members of classes in the aspx.cs
files.

Is that what you all do? (at least those of you who try to get re-use)

Anything else you do?
Nov 19 '05 #1
2 1336
Make all aspx.cs classes inherit from a class which inherits from page.

public class BasePage : Page
{
blah
}

pubic class Index : BasePage
{
OnLoad...
}

or you can use masterPages to do some of this, but that tends to be more for
UI inheritance...

Karl

--
MY ASP.Net tutorials
http://www.openmymind.net/

"Randall Parker" <NOtechieSPAMpundit_please@future_avoidjunk_pundit .com>
wrote in message news:uy**************@TK2MSFTNGP09.phx.gbl...
I've noticed that C# can only inherit from a single class. At the same
time, the CodeBehind in an aspx.cs file inherits from Page.

So what do you all do to reuse code in .aspx.cs classes?

Seems to me one has to create classes and make them members of classes in
the aspx.cs files.

Is that what you all do? (at least those of you who try to get re-use)

Anything else you do?

Nov 19 '05 #2
On Tue, 01 Nov 2005 10:28:40 -0800, Randall Parker wrote:
I've noticed that C# can only inherit from a single class. At the same time, the
CodeBehind in an aspx.cs file inherits from Page.

So what do you all do to reuse code in .aspx.cs classes?

Seems to me one has to create classes and make them members of classes in the aspx.cs
files.

Is that what you all do? (at least those of you who try to get re-use)

Anything else you do?

You can also use composition (include another class instance) and pass the
current context (Page.context)

Nov 19 '05 #3

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

Similar topics

242
by: James Cameron | last post by:
Hi I'm developing a program and the client is worried about future reuse of the code. Say 5, 10, 15 years down the road. This will be a major factor in selecting the development language. Any...
6
by: Mario T. Lanza | last post by:
Greetings, I don't know about you guys but on many occasions I've asked myself whether or not someone else has solved a particular programming issue -- whether or not they developed a clever...
0
by: Glenn Engelbart | last post by:
I am trying to find out a way to get more code re-use & object orientation in the UI portion of my apps. (There already is plenty of both in the DataAccess & Business Logic portion of my apps. ...
171
by: tshad | last post by:
I am just trying to decide whether to split my code and uses code behind. I did it with one of my pages and found it was quite a bit of trouble. I know that most people (and books and articles)...
1
by: Me | last post by:
Hi, I inherited a web application that has several very similar forms for gathering user data. User's must choose the form that best fits their needs and fill it out. Each form has about 15...
1
by: BillE | last post by:
Can I inherit from a web form? I would like to reuse procedures in a web form base class code behind by inheriting from it. For example, I would like to have a HandleError function defined in...
1
by: LiveCycle | last post by:
Hi, I'm putting together a project that uses ASP.NET in VS2005. It uses a single master page that is responsible for most of the heavy lifting. About 90% of the 200 pages have the same...
2
by: rn5a | last post by:
Assume that a user control (MyUC.ascx) encapsulates 2 TextBoxes with the IDs 'txt1' & 'txt2' respectively. To use this user control in an ASPX page, the following Register directive will be...
6
by: Bart Simpson | last post by:
I remember reading on parashift recently, that "Composition is for code reuse, inheritance is for flexibility" see (http://www.parashift.com/c++-faq-lite/smalltalk.html#faq-30.4) This confused...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
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: 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...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
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...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

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.