EmptyControlCollection Classe

Definição

Fornece suporte Standard para uma coleção ControlCollection que está sempre vazia.Provides standard support for a ControlCollection collection that is always empty.

public ref class EmptyControlCollection : System::Web::UI::ControlCollection
public class EmptyControlCollection : System.Web.UI.ControlCollection
type EmptyControlCollection = class
    inherit ControlCollection
Public Class EmptyControlCollection
Inherits ControlCollection
Herança
EmptyControlCollection

Exemplos


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

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 

Comentários

Essa classe é usada quando você deseja definir um controle personalizado que não permite controles filho.This class is used when you want to define a custom control that does not allow child controls.

Construtores

EmptyControlCollection(Control)

Inicializa uma nova instância da classe EmptyControlCollection.Initializes a new instance of the EmptyControlCollection class.

Propriedades

Count

Obtém o número de controles de servidor no objeto ControlCollection para o controle de servidor ASP.NET especificado.Gets the number of server controls in the ControlCollection object for the specified ASP.NET server control.

(Herdado de ControlCollection)
IsReadOnly

Obtém um valor que indica se o objeto ControlCollection é somente leitura.Gets a value indicating whether the ControlCollection object is read-only.

(Herdado de ControlCollection)
IsSynchronized

Obtém um valor que indica se o objeto ControlCollection está sincronizado.Gets a value indicating whether the ControlCollection object is synchronized.

(Herdado de ControlCollection)
Item[Int32]

Obtém uma referência para o controle de servidor no local do índice especificado no objeto ControlCollection.Gets a reference to the server control at the specified index location in the ControlCollection object.

(Herdado de ControlCollection)
Owner

Obtém o controle de servidor ASP.NET ao qual o objeto ControlCollection pertence.Gets the ASP.NET server control to which the ControlCollection object belongs.

(Herdado de ControlCollection)
SyncRoot

Obtém um objeto que pode ser usado para sincronizar o acesso à coleção de controels.Gets an object that can be used to synchronize access to the collection of controls.

(Herdado de ControlCollection)

Métodos

Add(Control)

Nega a adição do objeto Control especificado à coleção.Denies the addition of the specified Control object to the collection.

AddAt(Int32, Control)

Nega a adição do objeto Control especificado à coleção na posição de índice especificada.Denies the addition of the specified Control object to the collection, at the specified index position.

Clear()

Remove todos os controles do objeto ControlCollection do controle dde servidor atual.Removes all controls from the current server control's ControlCollection object.

(Herdado de ControlCollection)
Contains(Control)

Determina se o controle de servidor especificado está no objeto ControlCollection do controle de servidor pai.Determines whether the specified server control is in the parent server control's ControlCollection object.

(Herdado de ControlCollection)
CopyTo(Array, Int32)

Copia os controles filho armazenados no objeto ControlCollection para um objeto Array, começando no local do índice especificado no Array.Copies the child controls stored in the ControlCollection object to an Array object, beginning at the specified index location in the Array.

(Herdado de ControlCollection)
Equals(Object)

Determina se o objeto especificado é igual ao objeto atual.Determines whether the specified object is equal to the current object.

(Herdado de Object)
GetEnumerator()

Recupera um enumerador que pode iterar pelo objeto ControlCollection.Retrieves an enumerator that can iterate through the ControlCollection object.

(Herdado de ControlCollection)
GetHashCode()

Serve como a função de hash padrão.Serves as the default hash function.

(Herdado de Object)
GetType()

Obtém o Type da instância atual.Gets the Type of the current instance.

(Herdado de Object)
IndexOf(Control)

Recupera o índice de um objeto Control especificado na coleção.Retrieves the index of a specified Control object in the collection.

(Herdado de ControlCollection)
MemberwiseClone()

Cria uma cópia superficial do Object atual.Creates a shallow copy of the current Object.

(Herdado de Object)
Remove(Control)

Remove o servidor especificado do objeto ControlCollection do controle de servidor pai.Removes the specified server control from the parent server control's ControlCollection object.

(Herdado de ControlCollection)
RemoveAt(Int32)

Remove um controle filho, no local do índice especificado, do objeto ControlCollection.Removes a child control, at the specified index location, from the ControlCollection object.

(Herdado de ControlCollection)
ToString()

Retorna uma cadeia de caracteres que representa o objeto atual.Returns a string that represents the current object.

(Herdado de Object)

Métodos de Extensão

Cast<TResult>(IEnumerable)

Converte os elementos de um IEnumerable para o tipo especificado.Casts the elements of an IEnumerable to the specified type.

OfType<TResult>(IEnumerable)

Filtra os elementos de um IEnumerable com base em um tipo especificado.Filters the elements of an IEnumerable based on a specified type.

AsParallel(IEnumerable)

Habilita a paralelização de uma consulta.Enables parallelization of a query.

AsQueryable(IEnumerable)

Converte um IEnumerable em um IQueryable.Converts an IEnumerable to an IQueryable.

Aplica-se a