TemplateContainer イベント

名前 | 説明 | |
---|---|---|
![]() | DataBinding | サーバー コントロールがデータ ソースに連結すると発生します。 ( Control から継承されます。) |
![]() | Disposed | サーバー コントロールがメモリから解放されると発生します。これは、ASP.NET ページが要求されている場合のサーバー コントロールの有効期間における最終段階です。 ( Control から継承されます。) |
![]() | Init | サーバー コントロールが初期化されると発生します。これは、サーバー コントロールの有効期間における最初の手順です。 ( Control から継承されます。) |
![]() | Load | サーバー コントロールが Page オブジェクトに読み込まれると発生します。 ( Control から継承されます。) |
![]() | PreRender | Control オブジェクトの読み込み後、表示を開始する前に発生します。 ( Control から継承されます。) |
![]() | Unload | サーバー コントロールがメモリからアンロードされると発生します。 ( Control から継承されます。) |

関連項目
TemplateContainer クラスSystem.Web.UI.MobileControls 名前空間
MobileListItem クラス
その他の技術情報
Understanding ASP.NET Adaptive Renderingコンテナ コントロール
モバイル Web アプリケーションの作成
モバイル デバイス機能
TemplateContainer クラス
アセンブリ: System.Web.Mobile (system.web.mobile.dll 内)


モバイル コントロールに、デバイス テンプレートを使ったテンプレート レンダリング機能がある場合は、TemplateContainer 型の別のコントロール内にある各テンプレートのインスタンスを作成する必要があります。データ バインド式がテンプレートのコントロール内にある場合、式の Container 変数の型は常に TemplateContainer です。

TemplateContainer オブジェクトを使用して、DeviceSpecific オブジェクト内にテンプレートをモバイル形式で作成する方法を次のコード例に示します。
![]() |
---|
次のコード サンプルはシングルファイル コード モデルを使用しており、分離コード ファイルに直接コピーされた場合は正常に動作しない可能性があります。このコード サンプルは、拡張子が .aspx の空のテキスト ファイルにコピーする必要があります。Web フォームのコード モデルの詳細については、「ASP.NET Web ページのコード モデル」を参照してください。 |
<%@ Page Language="VB" Inherits="System.Web.UI.MobileControls.MobilePage" %> <%@ Register TagPrefix="mobile" Namespace="System.Web.UI.MobileControls" Assembly="System.Web.Mobile" %> <script runat="server"> Private Sub Form_Init(ByVal sender As Object, ByVal e As EventArgs) ' Create a DeviceSpecific group for Choice elements Dim devSpecific As New DeviceSpecific() Dim ipa As IParserAccessor ' Create two Choice objects, one with a filter For i As Integer = 0 To 1 Dim devChoice As DeviceSpecificChoice Dim custTemplate As ITemplate ' Create a Choice object devChoice = New DeviceSpecificChoice() ' Only the first Choice has a filter (must be in Web.config) If i = 0 Then devChoice.Filter = "isHTML32" ' Create the header template. custTemplate = New CustomTemplate("HeaderTemplate") ' Put header template in a new container custTemplate.InstantiateIn(New TemplateContainer()) ' Add the header template to the Choice devChoice.Templates.Add("HeaderTemplate", custTemplate) ' Create the footer template custTemplate = New CustomTemplate("FooterTemplate") ' Put footer template in a new container custTemplate.InstantiateIn(New TemplateContainer()) ' Add the footer template to the Choice devChoice.Templates.Add("FooterTemplate", custTemplate) End If ' Add the Choice to the DeviceSpecific ipa = CType(devSpecific, IParserAccessor) ipa.AddParsedSubObject(devChoice) Next ' Add the DeviceSpecific object to the form ipa = CType(Form1, IParserAccessor) ipa.AddParsedSubObject(devSpecific) End Sub Protected Sub Page_Load(ByVal sender As Object, _ ByVal e As EventArgs) Dim lab As System.Web.UI.MobileControls.Label lab = CType(Form1.Header.FindControl("Label1"), _ System.Web.UI.MobileControls.Label) If IsNothing(lab) Then Return ' Get the selected choice's filter name Dim filterName As String = _ Form1.DeviceSpecific.SelectedChoice.Filter If filterName = "isHTML32" Then lab.Text += " - HTML32" Else lab.Text += " - Default" End If End Sub Public Class CustomTemplate Implements ITemplate Dim templName As String ' Constructor Public Sub New(ByVal TemplateName As String) templName = TemplateName End Sub Public Sub InstantiateIn(ByVal container As Control) _ Implements ITemplate.InstantiateIn If templName = "HeaderTemplate" Then ' Create a label Dim lab As New System.Web.UI.MobileControls.Label lab.Text = "Header Template" lab.ID = "Label1" ' Create a command Dim cmd As New Command() cmd.Text = "Submit" ' Add controls to the container container.Controls.Add(lab) container.Controls.Add(cmd) ElseIf templName = "FooterTemplate" Then ' Create a label Dim lab As System.Web.UI.MobileControls.Label lab = New System.Web.UI.MobileControls.Label() lab.ID = "Label2" lab.Text = "Footer Template" ' Add label to the container container.Controls.Add(lab) End If End Sub End Class </script> <html xmlns="http:'www.w3.org/1999/xhtml" > <body> <mobile:form id="Form1" runat="server" OnInit="Form_Init"> </mobile:form> </body> </html>
<%@ Page Language="C#" Inherits="System.Web.UI.MobileControls.MobilePage" %> <%@ Register TagPrefix="mobile" Namespace="System.Web.UI.MobileControls" Assembly="System.Web.Mobile" %> <script runat="server"> private void Form_Init(object sender, System.EventArgs e) { // Create a DeviceSpecific group for Choice elements DeviceSpecific devSpecific = new DeviceSpecific(); // Create two Choice objects, one with a filter for (int i = 0; i < 2; i++) { DeviceSpecificChoice devChoice; ITemplate custTemplate; // Create a Choice object devChoice = new DeviceSpecificChoice(); // Only the first Choice has a filter (must be in Web.config) if (i == 0) devChoice.Filter = "isHTML32"; // Create the header template. custTemplate = new CustomTemplate("HeaderTemplate"); // Put header template in a new container custTemplate.InstantiateIn(new TemplateContainer()); // Add the header template to the Choice devChoice.Templates.Add("HeaderTemplate", custTemplate); // Create the footer template custTemplate = new CustomTemplate("FooterTemplate"); // Put footer template in a new container custTemplate.InstantiateIn(new TemplateContainer()); // Add the footer template to the Choice devChoice.Templates.Add("FooterTemplate", custTemplate); // Add the Choice to the DeviceSpecific ((IParserAccessor)devSpecific).AddParsedSubObject(devChoice); } // Add the DeviceSpecific object to the form ((IParserAccessor)Form1).AddParsedSubObject(devSpecific); } protected void Page_Load(object sender, EventArgs e) { System.Web.UI.MobileControls.Label lab; lab = (System.Web.UI.MobileControls.Label)Form1.Header.FindControl("Label1"); if (lab == null) return; // Get the selected choice's filter name string filterName = Form1.DeviceSpecific.SelectedChoice.Filter; if (filterName == "isHTML32") lab.Text += " - HTML32"; else lab.Text += " - Default"; } public class CustomTemplate : ITemplate { String templateName; // Constructor public CustomTemplate(string TemplateName) { templateName = TemplateName; } public void InstantiateIn(Control container) { if (templateName == "HeaderTemplate") { // Create a label System.Web.UI.MobileControls.Label lab; lab = new System.Web.UI.MobileControls.Label(); lab.Text = "Header Template"; lab.ID = "Label1"; // Create a command Command cmd = new Command(); cmd.Text = "Submit"; // Add controls to the container container.Controls.Add(lab); container.Controls.Add(cmd); } else if (templateName == "FooterTemplate") { // Create a label System.Web.UI.MobileControls.Label lab; lab = new System.Web.UI.MobileControls.Label(); lab.ID = "Label2"; lab.Text = "Footer Template"; // Add label to the container container.Controls.Add(lab); } } } </script> <html > <body> <mobile:form id="Form1" runat="server" OnInit="Form_Init"> </mobile:form> </body> </html>
上記のコードはすべて、宣言によって次のマークアップと置換できます。
<html > <body> <mobile:Form id="Form1" runat="server"> <mobile:DeviceSpecific Runat="server"> <Choice Filter="isHTML32"> <HeaderTemplate> <mobile:Label ID="Label1" Runat="server"> Header Template - HTML32</mobile:Label> <mobile:Command Runat="server"> Submit</mobile:Command> </HeaderTemplate> <FooterTemplate> <mobile:Label ID="Label2" Runat="server"> Footer Template</mobile:Label> </FooterTemplate> </Choice> <Choice> <HeaderTemplate> <mobile:Label ID="Label1" Runat="server"> Header Template - Default</mobile:Label> <mobile:Command ID="Command1" Runat="server"> Submit</mobile:Command> </HeaderTemplate> <FooterTemplate> <mobile:Label ID="Label2" Runat="server"> Footer Template</mobile:Label> </FooterTemplate> </Choice> </mobile:DeviceSpecific> </mobile:Form> </body> </html>


System.Web.UI.Control
System.Web.UI.MobileControls.MobileControl
System.Web.UI.MobileControls.Panel
System.Web.UI.MobileControls.TemplateContainer
System.Web.UI.MobileControls.MobileListItem


Windows 98, Windows 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


TemplateContainer コンストラクタ
アセンブリ: System.Web.Mobile (system.web.mobile.dll 内)


Windows 98, Windows 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


TemplateContainer プロパティ



関連項目
TemplateContainer クラスSystem.Web.UI.MobileControls 名前空間
MobileListItem クラス
その他の技術情報
Understanding ASP.NET Adaptive Renderingコンテナ コントロール
モバイル Web アプリケーションの作成
モバイル デバイス機能
TemplateContainer メソッド



関連項目
TemplateContainer クラスSystem.Web.UI.MobileControls 名前空間
MobileListItem クラス
その他の技術情報
Understanding ASP.NET Adaptive Renderingコンテナ コントロール
モバイル Web アプリケーションの作成
モバイル デバイス機能
TemplateContainer メンバ
Panel クラスから派生し、DeviceSpecificChoice テンプレートを格納するために ASP.NET によって使用されます。
TemplateContainer データ型で公開されるメンバを以下の表に示します。






名前 | 説明 | |
---|---|---|
![]() | DataBinding | サーバー コントロールがデータ ソースに連結すると発生します。(Control から継承されます。) |
![]() | Disposed | サーバー コントロールがメモリから解放されると発生します。これは、ASP.NET ページが要求されている場合のサーバー コントロールの有効期間における最終段階です。(Control から継承されます。) |
![]() | Init | サーバー コントロールが初期化されると発生します。これは、サーバー コントロールの有効期間における最初の手順です。(Control から継承されます。) |
![]() | Load | サーバー コントロールが Page オブジェクトに読み込まれると発生します。(Control から継承されます。) |
![]() | PreRender | Control オブジェクトの読み込み後、表示を開始する前に発生します。(Control から継承されます。) |
![]() | Unload | サーバー コントロールがメモリからアンロードされると発生します。(Control から継承されます。) |

関連項目
TemplateContainer クラスSystem.Web.UI.MobileControls 名前空間
MobileListItem クラス
その他の技術情報
Understanding ASP.NET Adaptive Renderingコンテナ コントロール
モバイル Web アプリケーションの作成
モバイル デバイス機能
- TemplateContainerのページへのリンク