LiteralControl.CreateControlCollection Method

Definition

Creates an EmptyControlCollection object for the current instance of the LiteralControl class.

C#
protected override System.Web.UI.ControlCollection CreateControlCollection();

Returns

The EmptyControlCollection for the current control.

Examples

The following code example overrides the CreateControlCollection method to create an instance of the ControlCollection class rather than an instance of the EmptyControlCollection class.

C#
[System.Security.Permissions.PermissionSet(System.Security.Permissions.SecurityAction.Demand, Name="FullTrust")] 
protected override ControlCollection CreateControlCollection()
{
   myControlCollection=new ControlCollection(this);
   return myControlCollection;
}

Remarks

By default, LiteralControl objects contain only text and no child server controls. If you want to change this behavior, you must override this method.

Applies to

Produkt Verzie
.NET Framework 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1

See also