System.Web.UI.Control.HasControls Method

Determines if the server control contains any child controls.

Syntax

public virtual bool HasControls ()

Returns

true if the control contains other controls; otherwise, false.

Remarks

Since this method simply determines if any child controls exist, it can enhance performance by allowing you to avoid an unnecessary ControlCollection.Count property call. Calls to this property require a System.Web.UI.ControlCollection object to be instantiated. If there are no children, this object creation wastes server resources.

Requirements

Namespace: System.Web.UI
Assembly: System.Web (in System.Web.dll)
Assembly Versions: 1.0.5000.0, 2.0.0.0