I have a public property on a custom control exposed like this:
public IList<KeyValuePair<ControlTypes, int>> ControlCollection {get;set;}
With ControlType as type enum like this:
public enum ControlTypes : int
{
DropDownList = 1,
TextBox = 2,
}
public ControlTypes ControlType {get;set;}
Basically I am trying to create a simple user control that will add a specified number of html controls based on the input of the ControlCollection property. Like this.
<x:CustomControl ID="abc" runat="server" ControlCollection="DropDownList,1,TextBox,5"/>
How would I ensure that the ControlCollection value开发者_如何学编程 is entered in a typesafe manner? Or is this even possible? Thanks.
I think you're looking for a Dictionary<TKey, TValue>
精彩评论