TemplateBasedControl.TemplateContainer property
SharePoint 2013
Gets the container control that instantiates the content template.
Assembly: Microsoft.SharePoint (in Microsoft.SharePoint.dll)
Property value
Type: Microsoft.SharePoint.WebControls.TemplateContainerA TemplateContainer object that instantiates the content template.
The following example shows how the TemplateContainer property can be used to obtain a reference to a control in a rendering template (defined in an .ascx file). See Walkthrough: Creating a Custom Field Type for the full example.
protected override void CreateChildControls() { if (this.Field != null && this.ControlMode != SPControlMode.Display) { // Make sure inherited child controls are completely rendered. base.CreateChildControls(); // Associate child controls in the .ascx file with the // fields allocated by this control. this.ISBNPrefix = (Label)TemplateContainer.FindControl("ISBNPrefix"); this.textBox = (TextBox)TemplateContainer.FindControl("TextField"); if (!this.Page.IsPostBack) { if (this.ControlMode == SPControlMode.New) { textBox.Text = "0-000-00000-0"; } // end assign default value in New mode }// end if this is not a postback //Do not reinitialize on a postback. }// end if there is a non-null underlying ISBNField and control mode is not Display // Do nothing if the ISBNField is null or control mode is Display. }