EmptyControlCollectionとは? わかりやすく解説

EmptyControlCollection クラス

常に空の ControlCollection コレクション標準サポート提供します

名前空間: System.Web.UI
アセンブリ: System.Web (system.web.dll 内)
構文構文

Public Class EmptyControlCollection
    Inherits ControlCollection
Dim instance As EmptyControlCollection
public class EmptyControlCollection : ControlCollection
public ref class EmptyControlCollection : public
 ControlCollection
public class EmptyControlCollection extends
 ControlCollection
public class EmptyControlCollection extends
 ControlCollection
解説解説
使用例使用例
' 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.Object
   System.Web.UI.ControlCollection
    System.Web.UI.EmptyControlCollection
スレッド セーフスレッド セーフ
この型の public static (Visual Basic では Shared) メンバはすべて、スレッド セーフです。インスタンス メンバ場合は、スレッド セーフであるとは限りません。
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照
関連項目
EmptyControlCollection メンバ
System.Web.UI 名前空間

EmptyControlCollection コンストラクタ

EmptyControlCollection クラス新しインスタンス初期化します。

名前空間: System.Web.UI
アセンブリ: System.Web (system.web.dll 内)
構文構文

Dim owner As Control

Dim instance As New EmptyControlCollection(owner)
public EmptyControlCollection (
    Control owner
)
public:
EmptyControlCollection (
    Control^ owner
)
public EmptyControlCollection (
    Control owner
)
public function EmptyControlCollection (
    owner : Control
)

パラメータ

owner

このコレクションを子コントロールコレクションとして所有している Control

使用例使用例

コントロールを持つコントロール設定しようとして例外発生するコード例次に示します。この例外は、コンテナ コントロールで子コントロール許可されていないために発生します実行可能ファイル作成するために使用されるコマンド ライン次に示します

vbc /r:System.dll /r:System.Web.dll /t:library
       /out:myWebAppPath/bin/vb_myEmptyControlCollection.dll
       myEmptyControlCollection.vb
csc /t:library /out:myWebAppPath/bin/cs_myEmptyControlCollection.dll
    myEmptyControlCollection.cs
' 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 ディレクティブ示される値には、前のコマンド ライン反映されます。

<%@ Register TagPrefix="custom" Assembly="vb_myEmptyControlCollection"
 Namespace="CustomControls" %>
 <html>
  <body>
  <h1>Using an Empty Control</h1>
  <custom:MyVB_EmptyControl id="vbEmptyControlId"
 runat="server"/>
  </body>
 </html>
<%@ Register TagPrefix="custom" Assembly="cs_myEmptyControlCollection"
 Namespace="CustomControls" %>
 <html>
  <body>
  <h1>Using an Empty Control </h1>
  <custom:MyCS_EmptyControl id="csEmptyControlId" runat="server"/>
  </body>
 </html>
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照
関連項目
EmptyControlCollection クラス
EmptyControlCollection メンバ
System.Web.UI 名前空間

EmptyControlCollection プロパティ


パブリック プロパティパブリック プロパティ

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

関連項目

EmptyControlCollection クラス
System.Web.UI 名前空間

EmptyControlCollection メソッド


パブリック メソッドパブリック メソッド

( プロテクト メソッド参照)
  名前 説明
パブリック メソッド Add オーバーライドされます指定した Control オブジェクトコレクションへの追加拒否します
パブリック メソッド AddAt オーバーライドされます指定した Control オブジェクトの、コレクション内の指定したインデックス位置への追加拒否します
パブリック メソッド Clear  現在のサーバー コントロールの ControlCollection オブジェクトからすべてのコントロール削除します。 ( ControlCollection から継承されます。)
パブリック メソッド Contains  指定したサーバー コントロールが親サーバー コントロールControlCollection オブジェクト内にあるかどうか確認します。 ( ControlCollection から継承されます。)
パブリック メソッド CopyTo  ControlCollection オブジェクト格納されている子コントロールを、System.Array オブジェクトに、System.Array 内の指定したインデックス位置からコピーします。 ( ControlCollection から継承されます。)
パブリック メソッド Equals  オーバーロードされます2 つObject インスタンス等しかどうか判断します。 ( Object から継承されます。)
パブリック メソッド GetEnumerator  ControlCollection オブジェクト反復処理できる列挙子を取得します。 ( ControlCollection から継承されます。)
パブリック メソッド GetHashCode  特定の型のハッシュ関数として機能します。GetHashCode は、ハッシュ アルゴリズムや、ハッシュ テーブルのようなデータ構造での使用適してます。 ( Object から継承されます。)
パブリック メソッド GetType  現在のインスタンスType取得します。 ( Object から継承されます。)
パブリック メソッド IndexOf  コレクション内の指定した Control オブジェクトインデックス取得します。 ( ControlCollection から継承されます。)
パブリック メソッド ReferenceEquals  指定した複数Object インスタンス同一かどうか判断します。 ( Object から継承されます。)
パブリック メソッド Remove  サーバー コントロールControlCollection オブジェクトから、指定したサーバー コントロール削除します。 ( ControlCollection から継承されます。)
パブリック メソッド RemoveAt  ControlCollection オブジェクトから、指定したインデックス位置にある子コントロール削除します。 ( ControlCollection から継承されます。)
パブリック メソッド ToString  現在の Object を表す String返します。 ( Object から継承されます。)
プロテクト メソッドプロテクト メソッド
参照参照

関連項目

EmptyControlCollection クラス
System.Web.UI 名前空間

EmptyControlCollection メンバ

常に空の ControlCollection コレクション標準サポート提供します

EmptyControlCollection データ型公開されるメンバを以下の表に示します


パブリック コンストラクタパブリック コンストラクタ
  名前 説明
パブリック メソッド EmptyControlCollection EmptyControlCollection クラス新しインスタンス初期化します。
パブリック プロパティパブリック プロパティ
( プロテクト プロパティ参照)
  名前 説明
パブリック プロパティ Count  指定されASP.NET サーバー コントロールControlCollection オブジェクト内にあるサーバー コントロールの数を取得します。(ControlCollection から継承されます。)
パブリック プロパティ IsReadOnly  ControlCollection オブジェクト読み取り専用かどうかを示す値を取得します。(ControlCollection から継承されます。)
パブリック プロパティ IsSynchronized  ControlCollection オブジェクト同期がとられているかどうかを示す値を取得します。(ControlCollection から継承されます。)
パブリック プロパティ Item  ControlCollection オブジェクト指定されインデックス位置にあるサーバー コントロールへの参照取得します。(ControlCollection から継承されます。)
パブリック プロパティ SyncRoot  コントロールコレクションへのアクセス同期するために使用するオブジェクト取得します。(ControlCollection から継承されます。)
プロテクト プロパティプロテクト プロパティ
パブリック メソッドパブリック メソッド
( プロテクト メソッド参照)
  名前 説明
パブリック メソッド Add オーバーライドされます指定した Control オブジェクトコレクションへの追加拒否します
パブリック メソッド AddAt オーバーライドされます指定した Control オブジェクトの、コレクション内の指定したインデックス位置への追加拒否します
パブリック メソッド Clear  現在のサーバー コントロールControlCollection オブジェクトからすべてのコントロール削除します。 (ControlCollection から継承されます。)
パブリック メソッド Contains  指定したサーバー コントロールが親サーバー コントロールControlCollection オブジェクト内にあるかどうか確認します。 (ControlCollection から継承されます。)
パブリック メソッド CopyTo  ControlCollection オブジェクト格納されている子コントロールを、System.Array オブジェクトに、System.Array 内の指定したインデックス位置からコピーします。 (ControlCollection から継承されます。)
パブリック メソッド Equals  オーバーロードされます2 つObject インスタンス等しかどうか判断します。 (Object から継承されます。)
パブリック メソッド GetEnumerator  ControlCollection オブジェクト反復処理できる列挙子を取得します。 (ControlCollection から継承されます。)
パブリック メソッド GetHashCode  特定の型のハッシュ関数として機能します。GetHashCode は、ハッシュ アルゴリズムや、ハッシュ テーブルのようなデータ構造での使用適してます。 (Object から継承されます。)
パブリック メソッド GetType  現在のインスタンスType取得します。 (Object から継承されます。)
パブリック メソッド IndexOf  コレクション内の指定した Control オブジェクトインデックス取得します。 (ControlCollection から継承されます。)
パブリック メソッド ReferenceEquals  指定した複数Object インスタンス同一かどうか判断します。 (Object から継承されます。)
パブリック メソッド Remove  サーバー コントロールControlCollection オブジェクトから、指定したサーバー コントロール削除します。 (ControlCollection から継承されます。)
パブリック メソッド RemoveAt  ControlCollection オブジェクトから、指定したインデックス位置にある子コントロール削除します。 (ControlCollection から継承されます。)
パブリック メソッド ToString  現在の Object を表す String返します。 (Object から継承されます。)
プロテクト メソッドプロテクト メソッド
参照参照

関連項目

EmptyControlCollection クラス
System.Web.UI 名前空間



英和和英テキスト翻訳>> Weblio翻訳
英語⇒日本語日本語⇒英語
  

辞書ショートカット

すべての辞書の索引

「EmptyControlCollection」の関連用語

EmptyControlCollectionのお隣キーワード
検索ランキング

   

英語⇒日本語
日本語⇒英語
   



EmptyControlCollectionのページの著作権
Weblio 辞書 情報提供元は 参加元一覧 にて確認できます。

   
日本マイクロソフト株式会社日本マイクロソフト株式会社
© 2024 Microsoft.All rights reserved.

©2024 GRAS Group, Inc.RSS