我在自定义控件上有一个公共属性,如下所示:
public IList<KeyValuePair<ControlTypes, int>> ControlCollection {get;set;}
使用 ControlType 作为枚举类型,如下所示:
public enum ControlTypes : int
{
DropDownList = 1,
TextBox = 2,
}
public ControlTypes ControlType {get;set;}
基本上我正在尝试创建一个简单的用户控件,它将根据 ControlCollection 属性的输入添加指定数量的 html 控件。像这样。
<x:CustomControl ID="abc" runat="server" ControlCollection="DropDownList,1,TextBox,5"/>
如何确保以类型安全的方式输入 ControlCollection 值?或者这甚至可能吗?谢谢。