[DefaultProperty("Text")] [Designer(typeof(ContainerControlDesigner))] [ParseChildren(false)] [ControlBuilderAttribute(typeof(SampleControlBuilder))] [ToolboxData("<{0}:Sample runat="server"></{0}:Sample>")] public class Sample: WebControl, INamingContainer { protected override void CreateChildControls() { System.Collections.IEnumerator myEnumerator = items.GetEnumerator(); while (myEnumerator.MoveNext()) this.Controls.Add((TextBox)myEnumerator.Current); } protected override void AddParsedSubObject(Object obj) { if (obj is TextBox) { items.Add(obj); } } } public class SampleControlBuilder : ControlBuilder { public override Type GetChildControlType(String tagName, IDictionary attributes) { if (String.Compare(tagName, "myitem", true) == 0) { return typeof(TextBox); } return null; } } public class SampleContainerControlDesigner : ContainerControlDesigner { public override bool AllowResize { get { return false; } } private Style _style = null; ublic override string FrameCaption { get { return "Dynamic Page Loader"; } } public override Style FrameStyle { get { if (_style == null) { _style = new Style(); _style.Font.Name = "Verdana"; _style.Font.Size = new FontUnit("XSmall"); _style.BackColor = Color.LightBlue; _style.ForeColor = Color.Black; } return _style; } } }
<cc1:Sample ID="Sample" runat="server" />
<cc1:Sample ID="Sample" runat="server" > <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox> </cc1:Sample
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)