EmptyControlCollection クラス
アセンブリ: System.Web (system.web.dll 内)



' File name: emptyControlCollection.vb. Imports System Imports System.Web Imports System.Web.UI Imports System.Web.UI.WebControls Imports System.Collections Namespace CustomControls Public Class MyVB_EmptyControl Inherits Control <System.Security.Permissions.PermissionSetAttribute(System.Security.Permissions.SecurityAction.Demand, Name:="FullTrust")> _ Protected Overrides Function CreateControlCollection() As ControlCollection ' Function Name: CreateControlCollection. ' Denies the creation of any child control by creating an empty collection. ' Generates an exception if an attempt to create a child control is made. Return New EmptyControlCollection(Me) End Function <System.Security.Permissions.PermissionSetAttribute(System.Security.Permissions.SecurityAction.Demand, Name:="FullTrust")> _ Protected Overrides Sub CreateChildControls() ' Sub Name: CreateChildControls. ' Populates the child control collection (Controls). ' Note: This function will cause an exception because the control does not allow ' child controls. Dim text As LiteralControl text = New LiteralControl("<h5>Composite Controls</h5>") Controls.Add(text) End Sub End Class End Namespace
/* File name: emptyControlCollection.cs. */ using System; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; using System.Collections; namespace CustomControls { // Defines a simple custom control. public class MyCS_EmptyControl : Control { [System.Security.Permissions.PermissionSet(System.Security.Permissions.SecurityAction.Demand, Name="FullTrust")] protected override ControlCollection CreateControlCollection() /* * Function Name: CreateControlCollection. * Denies the creation of any child control by creating an empty collection. * Generates an exception if an attempt to create a child control is made. */ { return new EmptyControlCollection(this); } [System.Security.Permissions.PermissionSet(System.Security.Permissions.SecurityAction.Demand, Name="FullTrust")] protected override void CreateChildControls() /* * Function Name: CreateChildControls. * Populates the child control collection (Controls). * Note: This function will cause an exception because the control does not allow * child controls. */ { // Create a literal control to contain the header and add it to the collection. LiteralControl text; text = new LiteralControl("<h5>Composite Controls</h5>"); Controls.Add(text); } } }
/* File name: emptyControlCollection.jsl. */ import System.*; import System.Web.*; import System.Web.UI.*; import System.Web.UI.WebControls.*; import System.Collections.*; // Defines a simple custom control. public class MyJSL_EmptyControl extends Control { // /** @attribute System.Security.Permissions.PermissionSet( // System.Security.Permissions.SecurityAction.Demand, Name = "FullTrust") // */ protected ControlCollection CreateControlCollection() /* Function Name: CreateControlCollection. Denies the creation of any child control by creating an empty collection. Generates an exception if an attempt to create a child control is made. */ { return new EmptyControlCollection(this); } //CreateControlCollection /** @attribute System.Security.Permissions.PermissionSet( System.Security.Permissions.SecurityAction.Demand, Name = "FullTrust") */ protected void CreateChildControls() /* Function Name: CreateChildControls. Populates the child control collection (Controls). Note: This function will cause an exception because the control does not allow child controls. */ { // Create a literal control to contain the header and add it to the // collection. LiteralControl text; text = new LiteralControl("<h5>Composite Controls</h5>"); get_Controls().Add(text); } //CreateChildControls } //MyJSL_EmptyControl

System.Web.UI.ControlCollection
System.Web.UI.EmptyControlCollection


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


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


子コントロールを持つコントロールを設定しようとして例外が発生するコード例を次に示します。この例外は、コンテナ コントロールで子コントロールが許可されていないために発生します。実行可能ファイルを作成するために使用されるコマンド ラインを次に示します。
vbc /r:System.dll /r:System.Web.dll /t:library /out:myWebAppPath/bin/vb_myEmptyControlCollection.dll myEmptyControlCollection.vb
' File name: emptyControlCollection.vb. Imports System Imports System.Web Imports System.Web.UI Imports System.Web.UI.WebControls Imports System.Collections Namespace CustomControls Public Class MyVB_EmptyControl Inherits Control <System.Security.Permissions.PermissionSetAttribute(System.Security.Permissions.SecurityAction.Demand, Name:="FullTrust")> _ Protected Overrides Function CreateControlCollection() As ControlCollection ' Function Name: CreateControlCollection. ' Denies the creation of any child control by creating an empty collection. ' Generates an exception if an attempt to create a child control is made. Return New EmptyControlCollection(Me) End Function <System.Security.Permissions.PermissionSetAttribute(System.Security.Permissions.SecurityAction.Demand, Name:="FullTrust")> _ Protected Overrides Sub CreateChildControls() ' Sub Name: CreateChildControls. ' Populates the child control collection (Controls). ' Note: This function will cause an exception because the control does not allow ' child controls. Dim text As LiteralControl text = New LiteralControl("<h5>Composite Controls</h5>") Controls.Add(text) End Sub End Class End Namespace
/* File name: emptyControlCollection.cs. */ using System; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; using System.Collections; namespace CustomControls { // Defines a simple custom control. public class MyCS_EmptyControl : Control { [System.Security.Permissions.PermissionSet(System.Security.Permissions.SecurityAction.Demand, Name="FullTrust")] protected override ControlCollection CreateControlCollection() /* * Function Name: CreateControlCollection. * Denies the creation of any child control by creating an empty collection. * Generates an exception if an attempt to create a child control is made. */ { return new EmptyControlCollection(this); } [System.Security.Permissions.PermissionSet(System.Security.Permissions.SecurityAction.Demand, Name="FullTrust")] protected override void CreateChildControls() /* * Function Name: CreateChildControls. * Populates the child control collection (Controls). * Note: This function will cause an exception because the control does not allow * child controls. */ { // Create a literal control to contain the header and add it to the collection. LiteralControl text; text = new LiteralControl("<h5>Composite Controls</h5>"); Controls.Add(text); } } }
/* File name: emptyControlCollection.jsl. */ import System.*; import System.Web.*; import System.Web.UI.*; import System.Web.UI.WebControls.*; import System.Collections.*; // Defines a simple custom control. public class MyJSL_EmptyControl extends Control { // /** @attribute System.Security.Permissions.PermissionSet( // System.Security.Permissions.SecurityAction.Demand, Name = "FullTrust") // */ protected ControlCollection CreateControlCollection() /* Function Name: CreateControlCollection. Denies the creation of any child control by creating an empty collection. Generates an exception if an attempt to create a child control is made. */ { return new EmptyControlCollection(this); } //CreateControlCollection /** @attribute System.Security.Permissions.PermissionSet( System.Security.Permissions.SecurityAction.Demand, Name = "FullTrust") */ protected void CreateChildControls() /* Function Name: CreateChildControls. Populates the child control collection (Controls). Note: This function will cause an exception because the control does not allow child controls. */ { // Create a literal control to contain the header and add it to the // collection. LiteralControl text; text = new LiteralControl("<h5>Composite Controls</h5>"); get_Controls().Add(text); } //CreateChildControls } //MyJSL_EmptyControl
上記で定義した空のカスタム コントロールを使用するコード例を次に示します。この例を実行すると、例外が発生します。Register ディレクティブに示される値には、前のコマンド ラインが反映されます。

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


EmptyControlCollection プロパティ

名前 | 説明 | |
---|---|---|
![]() | Count | 指定された ASP.NET サーバー コントロールの ControlCollection オブジェクト内にあるサーバー コントロールの数を取得します。 ( ControlCollection から継承されます。) |
![]() | IsReadOnly | ControlCollection オブジェクトが読み取り専用かどうかを示す値を取得します。 ( ControlCollection から継承されます。) |
![]() | IsSynchronized | ControlCollection オブジェクトの同期がとられているかどうかを示す値を取得します。 ( ControlCollection から継承されます。) |
![]() | Item | ControlCollection オブジェクトの指定されたインデックス位置にあるサーバー コントロールへの参照を取得します。 ( ControlCollection から継承されます。) |
![]() | SyncRoot | コントロールのコレクションへのアクセスを同期するために使用するオブジェクトを取得します。 ( ControlCollection から継承されます。) |


EmptyControlCollection メソッド


名前 | 説明 | |
---|---|---|
![]() | Finalize | Object がガベージ コレクションにより収集される前に、その Object がリソースを解放し、その他のクリーンアップ操作を実行できるようにします。 ( Object から継承されます。) |
![]() | MemberwiseClone | 現在の Object の簡易コピーを作成します。 ( Object から継承されます。) |

EmptyControlCollection メンバ
常に空の ControlCollection コレクションの標準サポートを提供します。
EmptyControlCollection データ型で公開されるメンバを以下の表に示します。


名前 | 説明 | |
---|---|---|
![]() | Count | 指定された ASP.NET サーバー コントロールの ControlCollection オブジェクト内にあるサーバー コントロールの数を取得します。(ControlCollection から継承されます。) |
![]() | IsReadOnly | ControlCollection オブジェクトが読み取り専用かどうかを示す値を取得します。(ControlCollection から継承されます。) |
![]() | IsSynchronized | ControlCollection オブジェクトの同期がとられているかどうかを示す値を取得します。(ControlCollection から継承されます。) |
![]() | Item | ControlCollection オブジェクトの指定されたインデックス位置にあるサーバー コントロールへの参照を取得します。(ControlCollection から継承されます。) |
![]() | SyncRoot | コントロールのコレクションへのアクセスを同期するために使用するオブジェクトを取得します。(ControlCollection から継承されます。) |



名前 | 説明 | |
---|---|---|
![]() | Finalize | Object がガベージ コレクションにより収集される前に、その Object がリソースを解放し、その他のクリーンアップ操作を実行できるようにします。 (Object から継承されます。) |
![]() | MemberwiseClone | 現在の Object の簡易コピーを作成します。 (Object から継承されます。) |

Weblioに収録されているすべての辞書からEmptyControlCollectionを検索する場合は、下記のリンクをクリックしてください。

- EmptyControlCollectionのページへのリンク