I would put my response in a comment, because I don't yet have an answer, but I don't have 50 rep so I can't comment.
This is a very interesting way of handling a User Control.
My question to you is, what are you trying to accomplish with this? We need to know, because your solution may not involve having a User Control that accepts any type - like Stilgar said.
You might could use an enumerator / property combo to accomplish this.. here's what I've come up with:
<uc1:MyGenericControl runat="server" id="MyGenericControl1" myControlType="DropDownList" />
public partial class MyGenericControl<T> : System.Web.UI.UserControl
{
public enum ucType : ushort
{
DropDownList = 1,
TextBox,
Button,
Etc
}
private ucType _controlType;
public ucType myControlType
{
get{return _controlType;}
set{ T = value; } /* Somehow set T to the value set in ASP.
In this example, value would be "1" so it would throw an error, but you get the idea. */
}
}
This is more suggestive and thought-provoking than a full answer, because I don't know if it's even possible to dynamically set a class type (especially one that you're currently working in). There is a Convert.ChangeType
method, but I don't think that would work here.