Name

ITemplate

Synopsis

Templates allow controls to make portions of their user interface configurable. Templates are used in classes like System.Web.UI.WebControls.DataList and can be added in your own custom controls by declaring properties of type ITemplate (for example, an ItemStyle or HeaderStyle property). This allows the user to specify a template for a portion of your control.

Your custom control code uses a supplied template by invoking the InstantiateIn() method. This method accepts a control reference and populates its Control.Controls collection with one or more server controls that represent the user interface defined in the template. The control you supply to the InstantiateIn() method could be the current control, or one of the current control’s children. Note that you do not need to write the implementation code for this method, as the .NET framework provides it intrinsically.

Public Interface ITemplate
                  ' Public Instance Methods
   Public Sub InstantiateIn(ByVal container As Control) 
End Interface

Get ASP.NET in a Nutshell now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.