TemplateContainerAttribute Class
Declares the base type of the container control of a property that returns an ITemplate interface and is marked with the TemplateContainerAttribute attribute. The control with the ITemplate property must implement the INamingContainer interface. This class cannot be inherited.
Assembly: System.Web (in System.Web.dll)
The Type object that is passed in as a parameter of the TemplateContainerAttribute object is used by the parser as the type of Container object that is used in data-binding expressions. The control whose property returns an ITemplate interface and is marked with the TemplateContainerAttribute, must implement the INamingContainer interface.
For more information about using attributes, see Extending Metadata Using Attributes.
| Topic | Location |
|---|---|
| How to: Create Templated ASP.NET User Controls | Building ASP .NET Web Applications |
| How to: Create Templated ASP.NET User Controls | Building ASP .NET Web Applications |
The following code example demonstrates how to create a templated control named TemplatedFirstControl and associate it with a container named FirstTemplateContainer. This allows the creation of custom controls that display the server time when the template is not specified and the template's content when the template is specified.
The following Web form demonstrates how to use the custom control created in the preceding code example. Two instances of the TemplatedFirstControl are placed on the page:
The first instance includes the template <FirstTemplate>.
The second instance does not include <FirstTemplate>; therefore, it shows just the time.
- AspNetHostingPermission
for operating in a hosted environment. Demand value: LinkDemand; Permission value: Minimal.
Windows 7, Windows Vista, Windows XP SP2, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP Starter Edition, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003, Windows Server 2000 SP4, Windows Millennium Edition, Windows 98
The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.