Click or drag to resize
SingleTemplateContainer Class
Base control used to contain a template. Ensures that if the template has been instantiated or the Controls collection has been accessed the template cannot be set again.
Inheritance Hierarchy
SystemObject
  System.Web.UIControl
    System.Web.UI.WebControlsWebControl
      System.Web.UI.WebControlsPanel
        Kettic.AspNet.ControlsSingleTemplateContainer

Namespace: Kettic.AspNet.Controls
Assembly: Kettic.AspNet.Controls (in Kettic.AspNet.Controls.dll) Version: 2014.4.1129.0 (2014.04.1129.0)
Syntax
public class SingleTemplateContainer : Panel, 
	INamingContainer

The SingleTemplateContainer type exposes the following members.

Methods
  NameDescription
Public methodHasControls (Overrides ControlHasControls.)
Top
Properties
  NameDescription
Public propertyControls (Overrides ControlControls.)
Top
Examples
1) Into an existing WebControl add a readonly property and a member for the template container private SingleTemplateContainer _contentContainer; [Browsable(false)] public SingleTemplateContainer ContentContainer { get { EnsureChildControls(); return _contentContainer; } } 2) Override CreateChildControls() and instantiate the SingleTemplateContainer. The parameter is a reference to the instantiating control (used when throwing exceptions). protected override void CreateChildControls() { base.CreateChildControls(); _contentContainer = new SingleTemplateContainer(this); _contentContainer.ID = "Content"; Controls.Add(_contentContainer); } 3) Add read/write property for the template. You will need the TemplateContainer attribute in case if you override SingleTemplateContainer in order to add properties, accessible during the databinding. //[TemplateContainer(typeof(SingleTemplateContainer))] [PersistenceMode(PersistenceMode.InnerProperty)] [TemplateInstance(TemplateInstance.Single)] [Browsable(false)] public ITemplate ContentTemplate { get { EnsureChildControls(); return ContentContainer.Template; } set { EnsureChildControls(); ContentContainer.Template = value; } }
See Also