Export (0) Print
Expand All

ITemplate.InstantiateIn Method

When implemented by a class, defines the Control object that child controls and templates belong to. These child controls are in turn defined within an inline template.

[Visual Basic]
Sub InstantiateIn( _
   ByVal container As Control _
)
[C#]
void InstantiateIn(
   Control container
);
[C++]
void InstantiateIn(
   Control* container
);
[JScript]
function InstantiateIn(
   container : Control
);

Parameters

container
The Control object to contain the instantiated controls from the inline template.

Remarks

When developing templated server controls you do not need to implement this method, the .NET Framework provides the implementation for you.

Example

[Visual Basic] 
' Override the ITemplate.InstantiateIn method to ensure 
' that the templates are created in a Literal control and
' that the Literal object's DataBinding event is associated
' with the BindData method.
Public Sub InstantiateIn(container As Control) Implements ITemplate.InstantiateIn
   Dim l As New Literal()
   AddHandler l.DataBinding, AddressOf Me.BindData
   container.Controls.Add(l)
End Sub 'InstantiateIn


[C#] 
// Override the ITemplate.InstantiateIn method to ensure 
// that the templates are created in a Literal control and
// that the Literal object's DataBinding event is associated
// with the BindData method.
public void InstantiateIn(Control container)
{
    Literal l = new Literal();
    l.DataBinding += new EventHandler(this.BindData);
    container.Controls.Add(l);
}

[C++] 
// Override the ITemplate.InstantiateIn method to ensure
// that the templates are created in a Literal control and
// that the Literal object's DataBinding event is associated
// with the BindData method.
public:
void InstantiateIn(Control* container) {
   Literal* l = new Literal();
   l->DataBinding += new EventHandler(this, &GenericItem::BindData);
   container->Controls->Add(l);
}

[JScript] No example is available for JScript. To view a Visual Basic, C#, or C++ example, click the Language Filter button Language Filter in the upper-left corner of the page.

Requirements

Platforms: Windows 2000, Windows XP Professional, Windows Server 2003 family

See Also

ITemplate Interface | ITemplate Members | System.Web.UI Namespace | Control | ControlCollection

Show:
© 2014 Microsoft