M
mark.norgate
I've run into a few problems trying to use generics for user controls
(classes derived from UserControl). I'm using the Web Application model
rather than the Web Site model.
The first problem I'm having is that the partial class signature in my
projectDetails.ascx.cs file looks like this:
public partial class ProjectDetailsControl<TEntryServiceProvider> :
UserControl, INamingContainer where TEntryServiceProvider :
IEntryServiceProvider {...}
....and no matter what I put in the corresponding projectDetails.ascx
file's Inherits attribute, the compiler complains. I have tried:
Inherits="Epic.Timesheet.Controls.ProjectDetailsControl"
....but then this creates an entirely different class in the
projectDetails.ascx.designer.cs and so none of the controls are
available to the class, since the two do not merge at compile time. I
then tried:
Inherits="Epic.Timesheet.Controls.ProjectDetailsControl<TEntryServiceProvider>"
But then at run time I get:
Parser Error Message: Could not load type
'Epic.Timesheet.Controls.ProjectDetailsControl<TEntryServiceProvider>'.
....which I don't quite understand, so I tried:
Inherits="Epic.Timesheet.Controls.ProjectDetailsControl<TEntryServiceProvider>
where TEntryServiceProvider : IEntryServiceProvider"
....which results in the same message. Finally, I tried the whole
signature:
Inherits="Epic.Timesheet.Controls.ProjectDetailsControl<TEntryServiceProvider>
: UserControl, INamingContainer where TEntryServiceProvider :
IEntryServiceProvider"
....but then projectDetails.ascx.designer.cs fails to compile because
UserControl cannot be found.
Gah!
Is it possible to use generics with user controls in this way? Or
should I reluctantly resort to using inheritance rather than generics
to provide these varying behaviours?
Mark
(classes derived from UserControl). I'm using the Web Application model
rather than the Web Site model.
The first problem I'm having is that the partial class signature in my
projectDetails.ascx.cs file looks like this:
public partial class ProjectDetailsControl<TEntryServiceProvider> :
UserControl, INamingContainer where TEntryServiceProvider :
IEntryServiceProvider {...}
....and no matter what I put in the corresponding projectDetails.ascx
file's Inherits attribute, the compiler complains. I have tried:
Inherits="Epic.Timesheet.Controls.ProjectDetailsControl"
....but then this creates an entirely different class in the
projectDetails.ascx.designer.cs and so none of the controls are
available to the class, since the two do not merge at compile time. I
then tried:
Inherits="Epic.Timesheet.Controls.ProjectDetailsControl<TEntryServiceProvider>"
But then at run time I get:
Parser Error Message: Could not load type
'Epic.Timesheet.Controls.ProjectDetailsControl<TEntryServiceProvider>'.
....which I don't quite understand, so I tried:
Inherits="Epic.Timesheet.Controls.ProjectDetailsControl<TEntryServiceProvider>
where TEntryServiceProvider : IEntryServiceProvider"
....which results in the same message. Finally, I tried the whole
signature:
Inherits="Epic.Timesheet.Controls.ProjectDetailsControl<TEntryServiceProvider>
: UserControl, INamingContainer where TEntryServiceProvider :
IEntryServiceProvider"
....but then projectDetails.ascx.designer.cs fails to compile because
UserControl cannot be found.
Gah!
Is it possible to use generics with user controls in this way? Or
should I reluctantly resort to using inheritance rather than generics
to provide these varying behaviours?
Mark