|
.net
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Code reuse, code behind, and can't inherit since already inherits PageI'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? 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 Show quoteHide quote "Randall Parker" <NOtechieSPAMpundit_please@future_avoidjunk_pundit.com> wrote in message news:uyFrWIx3FHA.2532@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? 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 You can also use composition (include another class instance) and pass 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? current context (Page.context)
Other interesting topics
maximum datagrid row count?
Pre compiling web site in 2.0 webconfig file How can I stop ASPX file rendering in Page_Load event? Help on Store procedure and ASP web page Upload if files from client PC or local network Finding a control VS2005 - unable to create a website in IIS ASP.NET 2 ICallbackEventHandler User controls breaking in designer |
|||||||||||||||||||||||