|
.net
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Inheritance of controls & pagesapplicaiton, 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 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. Show quoteHide quote "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
Other interesting topics
ASP.NET 2.0 menu: where to set alternate text for "^ up one level
disabling html validation does not seem to stck Application Performance Question Issues with multiple website development on Windows 2000 pro box Problems with ASP.NET 2.0 menu with Safari Error - System.Data.OleDb.OleDbException: Could not use ''; file already in use. - please help Need Step by Step guide for setting up IIS 6 for ASP Question on string DataGrid Columns Spannig More Than One Column Referencing other web projects within Visual Studio 2005 |
|||||||||||||||||||||||