Base classes for the page and UserControl:
public class MyWebPage : System.Web.UI.Page { }
public class MyUserControl : System.Web.UI.UserControl { }
An assistant who can use any of them:
void SetSessionValue<T>(string key, T value) { Session[key] = value; }
How can I achieve something like the following?
public class WebObject // can't inherit from both Page and UserControl {
protected void SetSessionValue<T>(string key, T value) {
Session[key] = value;
}
}
public class MyWebPage : WebObject { }
public class MyUserControl : WebObject { }
Update: I was excited that I hoped I could solve it, but, alas, it does not compile.
public class WebObject<T> : T
{
}
public class MyWebPage : WebObject<System.Web.UI.Page>
{
}
source
share