views:

112

answers:

2

Is there a way that I can have a server control

MyControl<T>

so that I can register and use it in an aspx page like so

<mc:MyControl<ThingForControlToUse> ID="instanceOfMyControl" runat="server"

Obviously the designer doesn't like this, are there any cool ways round it other than creating a non generic wrapper with a type parameter?

+4  A: 

Generic Tag Names are not possible in ASP.NET, please refer to this article: Generic Controls

You are on the right track in thinking that you will need to create a wrapper with a TYPE parameter.

ichiban
The idea in the article is really quite cool, I misunderstood at first, but having implemented it, it worked well. Thanks a lot.
Mark Dickinson
A: 

A quick note - I am not sure if this is true in Visual Studio 2008 but if you were to have that control in a project that you were editing with Visual Studio 2005 you would completely break intellisense with that control. When Visual Studio attempts to create XML schema files to use for intellisense popups in markup files it completely breaks when it sees generic controls like this one and it abandons the schema file completely leaving you with no intellisense for any controls in that assembly.

Andrew Hare