[ParseChildren(true)] public partial class Rainbow : UserControl { [DesignerSerializationVisibility( DesignerSerializationVisibility.Visible)] [PersistenceMode(PersistenceMode.InnerProperty)] public List<RainbowColor> Colors { get; set; } protected override void AddParsedSubObject(object obj) { if (obj.GetType() == typeof(RainbowColor)) this.Colors.Add((RainbowColor)obj); else base.AddParsedSubObject(obj); } } public class RainbowColor : WebControl, INamingContainer { public RainbowColorType Color { get; set; } } public enum RainbowColorType { Red, Blue, Yellow, Green, Indigo, Orange, Violet }
Markup:
<asp:Rainbow runat="server" ID="rbwCurrent"> <Colors> <asp:RainbowColor Color="Blue" /> <asp:RainbowColor Color="Red" /> </Colors> </asp:Rainbow>
No comments:
Post a Comment