C
Chris Peeters
Hi.
Instead of having 2 webforms that do similar things, apart from the type
of data they are using, I want to create a generic version of the page
So, instead of having 2 classes
public partial class IntPage : System.Web.UI.Page
{
public IntPage()
{
List<int> i = new List<int>();
}
}
public partial class StringPage : System.Web.UI.Page
{
public StringPage()
{
List<string> i = new List<string>();
}
}
do i want just one, something like
public partial class TestPage<T> : System.Web.UI.Page
{
public TestPage()
{
List<T> i = new List<T>();
}
}
And so, based on the request of the client does he get the int-page or
the string-page.
But how to implement this ? In order to create an instance of the
generic class, where do i write the instance creation code?
Where is the point in the request-pipeline where the instance of a
webpage is created, in other words, where can i write my generic class
creation, something like :
HttpContext.Current.Handler = new TestPage<int>();
or
HttpContext.Current.Handler = new TestPage<string>();
any help greatly appreciated
thank you
Chris
Instead of having 2 webforms that do similar things, apart from the type
of data they are using, I want to create a generic version of the page
So, instead of having 2 classes
public partial class IntPage : System.Web.UI.Page
{
public IntPage()
{
List<int> i = new List<int>();
}
}
public partial class StringPage : System.Web.UI.Page
{
public StringPage()
{
List<string> i = new List<string>();
}
}
do i want just one, something like
public partial class TestPage<T> : System.Web.UI.Page
{
public TestPage()
{
List<T> i = new List<T>();
}
}
And so, based on the request of the client does he get the int-page or
the string-page.
But how to implement this ? In order to create an instance of the
generic class, where do i write the instance creation code?
Where is the point in the request-pipeline where the instance of a
webpage is created, in other words, where can i write my generic class
creation, something like :
HttpContext.Current.Handler = new TestPage<int>();
or
HttpContext.Current.Handler = new TestPage<string>();
any help greatly appreciated
thank you
Chris