I have two classes that my pages and controls inherit from. These two classes get the same basic set of information, but as it stands the code is implemented twice. Is there a way to inherit from one base class?
public partial class SessionPage : System.Web.UI.Page
{
protected override void OnInit(EventArgs e)
{
// Loads the session information from the database
// stores in member vars for the page to use
}
}
public partial class SessionControl : System.Web.UI.UserControl
{
protected override void OnInit(EventArgs e)
{
// Loads the session information from the database
// stores in member vars for the user control to use
}
}
Have a look at this stackoverflow post which treats somehow your issue.
Your
could be implemented as an extension method which would allow you to reuse the logic inside both, the page and usercontrol.