Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Code reuse, code behind, and can't inherit since already inheritsPage

Reply
Thread Tools

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

 
 
Randall Parker
Guest
Posts: n/a
 
      11-01-2005
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?
 
Reply With Quote
 
 
 
 
Karl Seguin
Guest
Posts: n/a
 
      11-01-2005
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:(E-Mail Removed)...
> 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?



 
Reply With Quote
 
 
 
 
intrader
Guest
Posts: n/a
 
      11-01-2005
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)

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Reason why enums since JDK1.5 cannot inherit Olli Plough Java 5 12-18-2007 01:50 AM
transparent and inherit of background Edwin van der Vaart HTML 9 10-21-2005 08:06 PM
Can we inherit a class and it's aspx ahead ad ASP .Net 3 05-12-2005 12:59 PM
Codebehind and inherit questions Thomas Scheiderich ASP .Net 2 06-18-2004 06:15 AM
VStudio and ASP.NET problem/limitation when pages inherit from an Abstract class? DesignerX ASP .Net 0 08-07-2003 09:35 PM



Advertisments