Cette documentation est archivée et n’est pas conservée.

EmptyControlCollection, classe

Mise à jour : novembre 2007

Assure la prise en charge standard de la collection ControlCollection toujours vide.

Espace de noms :  System.Web.UI
Assembly :  System.Web (dans System.Web.dll)

[AspNetHostingPermissionAttribute(SecurityAction.InheritanceDemand, Level = AspNetHostingPermissionLevel.Minimal)]
[AspNetHostingPermissionAttribute(SecurityAction.LinkDemand, Level = AspNetHostingPermissionLevel.Minimal)]
public class EmptyControlCollection : ControlCollection
/** @attribute AspNetHostingPermissionAttribute(SecurityAction.InheritanceDemand, Level = AspNetHostingPermissionLevel.Minimal) */
/** @attribute AspNetHostingPermissionAttribute(SecurityAction.LinkDemand, Level = AspNetHostingPermissionLevel.Minimal) */
public class EmptyControlCollection extends ControlCollection
public class EmptyControlCollection extends ControlCollection

Cette classe est utilisée lorsque vous souhaitez définir un contrôle personnalisé n'autorisant pas de contrôle enfant.


/* 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

Tous les membres static (Shared en Visual Basic) publics de ce type sont thread-safe. Il n'est pas garanti que les membres d'instance soient thread-safe.

Windows Vista, Windows XP SP2, Windows XP Media Center Edition, Windows XP Professionnel Édition x64, Windows XP Starter Edition, Windows Server 2003, Windows Server 2000 SP4, Windows Millennium Edition, Windows 98

Le .NET Framework et le .NET Compact Framework ne prennent pas en charge toutes les versions de chaque plateforme. Pour obtenir la liste des versions prises en charge, consultez Configuration requise du .NET Framework.

.NET Framework

Pris en charge dans : 3.5, 3.0, 2.0, 1.1, 1.0
Afficher: