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 对象仅包含文本,不包含子服务器控件。 如果要更改此行为,则必须重写此方法。

适用于

另请参阅