Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>You need something like this. Everything is ok, but you have to complete the TabCollection class.</p> <p><strong>Edit:</strong> Pardon me, I didn't test the code. Anyway found some problems so resolved them.</p> <p><strong>UserControl</strong></p> <pre><code>[ParseChildren(true, "Tabs"), PersistChildren(false)] public partial class TabMenu : UserControl { private TabCollection _tabs; [Browsable(false), PersistenceMode(PersistenceMode.InnerProperty), MergableProperty(false)] public virtual TabCollection Tabs { get { if (this._tabs == null) this._tabs = new TabCollection(this); return this._tabs; } } protected override ControlCollection CreateControlCollection() { return new TabMenuControlCollection(this); } } </code></pre> <p><strong>Tab</strong></p> <pre><code>public class Tab : HtmlGenericControl { public string Label { get { return (string)ViewState["Label"] ?? string.Empty; } set { ViewState["Label"] = value; } } } </code></pre> <p><strong>TabCollection</strong></p> <pre><code>public class TabCollection : IList, ICollection, IEnumerable { private TabMenu _tabMenu; public TabCollection(TabMenu tabMenu) { if (tabMenu == null) throw new ArgumentNullException("tabMenu"); this._tabMenu = tabMenu; } public virtual int Add(Tab tab) { if (tab == null) throw new ArgumentNullException("tab"); this._tabMenu.Controls.Add(tab); return this._tabMenu.Controls.Count - 1; } int IList.Add(object value) { return this.Add((Tab)value); } // You have to write other methods and properties as Add. } </code></pre> <p><strong>TabMenuControlCollection</strong></p> <pre><code>public class TabMenuControlCollection : ControlCollection { public TabMenuControlCollection(TabMenu owner) : base(owner) { } public override void Add(Control child) { if (child == null) throw new ArgumentNullException("child"); if (!(child is TabMenu)) throw new ArgumentException("The TabMenu control can only have a child of type 'Tab'."); base.Add(child); } public override void AddAt(int index, Control child) { if (child == null) throw new ArgumentNullException("child"); if (!(child is TabMenu)) throw new ArgumentException("The TabMenu control can only have a child of type 'Tab'."); base.AddAt(index, child); } } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload