共用方式為


LiteralControl.CreateControlCollection 方法

定義

EmptyControlCollection 類別的目前執行個體,建立 LiteralControl 物件。

protected:
 override System::Web::UI::ControlCollection ^ CreateControlCollection();
protected override System.Web.UI.ControlCollection CreateControlCollection ();
override this.CreateControlCollection : unit -> System.Web.UI.ControlCollection
Protected Overrides Function CreateControlCollection () As ControlCollection

傳回

目前控制項的 EmptyControlCollection

範例

下列程式碼範例會 CreateControlCollection 覆寫 方法來建立 類別的 ControlCollection 實例,而不是 類別的 EmptyControlCollection 實例。

[System.Security.Permissions.PermissionSet(System.Security.Permissions.SecurityAction.Demand, Name="FullTrust")] 
protected override ControlCollection CreateControlCollection()
{
   myControlCollection=new ControlCollection(this);
   return myControlCollection;
}
<System.Security.Permissions.PermissionSetAttribute(System.Security.Permissions.SecurityAction.Demand, Name:="FullTrust")> _
Protected Overrides Function CreateControlCollection() As ControlCollection
   myControlCollection = New ControlCollection(Me)
   Return myControlCollection
End Function 'CreateControlCollection

備註

根據預設, LiteralControl 物件只包含文字,而且沒有子伺服器控制項。 如果您想要變更此行為,您必須覆寫這個方法。

適用於

另請參閱