New to Telerik UI for ASP.NET AJAX? Start a free 30-day trial

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.

Definition

Namespace:Telerik.Web.UI

Assembly:Telerik.Web.UI.dll

Syntax:

C#
public class SingleTemplateContainer : Panel, IComponent, IDisposable, IParserAccessor, IUrlResolutionService, IDataBindingsAccessor, IControlBuilderAccessor, IControlDesignerAccessor, IExpressionsAccessor, IAttributeAccessor, INamingContainer

Inheritance: objectControlWebControlPanelSingleTemplateContainer

Implements: IAttributeAccessorIComponentIControlBuilderAccessorIControlDesignerAccessorIDataBindingsAccessorIDisposableIExpressionsAccessorINamingContainerIParserAccessorIUrlResolutionService...

Inherited Members Panel.AddAttributesToRender(HtmlTextWriter)Panel.CreateControlStyle()Panel.RenderBeginTag(HtmlTextWriter)Panel.RenderEndTag(HtmlTextWriter)Panel.BackImageUrlPanel.DefaultButtonPanel.DirectionPanel.GroupingTextPanel.HorizontalAlignPanel.SupportsDisabledAttributePanel.ScrollBarsPanel.WrapWebControl.ApplyStyle(Style)WebControl.CopyBaseAttributes(WebControl)WebControl.LoadViewState(object)WebControl.TrackViewState()WebControl.MergeStyle(Style)WebControl.Render(HtmlTextWriter)WebControl.RenderContents(HtmlTextWriter)WebControl.SaveViewState()WebControl.AccessKeyWebControl.AttributesWebControl.BackColorWebControl.BorderColorWebControl.BorderWidthWebControl.BorderStyleWebControl.ControlStyleWebControl.ControlStyleCreatedWebControl.CssClassWebControl.DisabledCssClassWebControl.StyleWebControl.EnabledWebControl.EnableThemingWebControl.FontWebControl.ForeColorWebControl.HasAttributesWebControl.HeightWebControl.IsEnabledWebControl.SkinIDWebControl.TabIndexWebControl.TagKeyWebControl.TagNameWebControl.ToolTipWebControl.WidthControl.ResolveAdapter()Control.HasEvents()Control.GetRouteUrl(object)Control.GetRouteUrl(string, object)Control.GetRouteUrl(RouteValueDictionary)Control.GetRouteUrl(string, RouteValueDictionary)Control.GetUniqueIDRelativeTo(Control)Control.ApplyStyleSheetSkin(Page)Control.OnDataBinding(EventArgs)Control.DataBind()Control.DataBind(bool)Control.DataBindChildren()Control.AddParsedSubObject(object)Control.EnsureID()Control.ClearChildState()Control.ClearChildControlState()Control.ClearChildViewState()Control.ClearEffectiveClientIDMode()Control.ClearCachedClientID()Control.Focus()Control.LoadControlState(object)Control.MapPathSecure(string)Control.OpenFile(string)Control.OnLoad(EventArgs)Control.OnPreRender(EventArgs)Control.BuildProfileTree(string, bool)Control.SaveControlState()Control.RenderChildren(HtmlTextWriter)Control.RenderControl(HtmlTextWriter)Control.RenderControl(HtmlTextWriter, ControlAdapter)Control.OnUnload(EventArgs)Control.Dispose()Control.RaiseBubbleEvent(object, EventArgs)Control.OnBubbleEvent(object, EventArgs)Control.AddedControl(Control, int)Control.CreateControlCollection()Control.ResolveUrl(string)Control.ResolveClientUrl(string)Control.FindControl(string)Control.FindControl(string, int)Control.GetDesignModeState()Control.IsLiteralContent()Control.EnsureChildControls()Control.RemovedControl(Control)Control.SetDesignModeState(IDictionary)Control.SetRenderMethodDelegate(RenderMethod)Control.ClientIDModeControl.ClientIDControl.ClientIDSeparatorControl.ContextControl.AdapterControl.DesignModeControl.EventsControl.IDControl.IsChildControlStateClearedControl.EnableViewStateControl.ViewStateModeControl.IsViewStateEnabledControl.NamingContainerControl.IdSeparatorControl.LoadViewStateByIDControl.PageControl.RenderingCompatibilityControl.TemplateControlControl.ParentControl.TemplateSourceDirectoryControl.AppRelativeTemplateSourceDirectoryControl.SiteControl.VisibleControl.UniqueIDControl.HasChildViewStateControl.ValidateRequestModeControl.ViewStateControl.ViewStateIgnoresCaseControl.ChildControlsCreatedControl.IsTrackingViewStateControl.DisposedControl.DataBindingControl.InitControl.LoadControl.PreRenderControl.Unloadobject.ToString()object.Equals(object)object.Equals(object, object)object.ReferenceEquals(object, object)object.GetHashCode()object.GetType()object.MemberwiseClone()...

Example:

  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; } }

  1. 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);

}

  1. 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; } }

Properties

C#
public override ControlCollection Controls { get; }

Overrides: Control.Controls

Methods

C#
protected override void CreateChildControls()

Overrides: Control.CreateChildControls()

C#
public override bool HasControls()
Returns:

bool

Overrides: Control.HasControls()

C#
protected virtual void InstantiateTemplate()
C#
protected override void OnInit(EventArgs e)
Parameters:eEventArgs

Overrides: Control.OnInit(EventArgs)