クラスによって実装されている場合は、子コントロールとテンプレートが属する Control オブジェクトを定義します。これらの子コントロールは、インライン テンプレート内で順番に定義されます。
Sub InstantiateIn( _
ByVal container As Control _)
[C#]
void InstantiateIn(
Controlcontainer);
[C++]
void InstantiateIn(
Control* container);
[JScript]
function InstantiateIn(
container : Control);
パラメータ
- container
インライン テンプレートからインスタンス化されたコントロールを格納する Control オブジェクト。
解説
このメソッドを実装する必要がないサーバー コントロールをテンプレートを使用して開発する場合は、.NET Framework によって実装が行われます。
使用例
' 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] JScript のサンプルはありません。Visual Basic、C#、および C++ のサンプルを表示するには、このページの左上隅にある言語のフィルタ ボタン をクリックします。
必要条件
プラットフォーム: Windows 2000, Windows XP Professional, Windows Server 2003 ファミリ
参照
ITemplate インターフェイス | ITemplate メンバ | System.Web.UI 名前空間 | Control | ControlCollection