System.Web.UI.Control.EnsureChildControls Method

Determines whether the server control contains child controls. If it does not, it creates child controls.

Syntax

protected virtual void EnsureChildControls ()

Remarks

This method first checks the current value of the Control.ChildControlsCreated property. If this value is false, the Control.CreateChildControls method is called.

The Control.EnsureChildControls method is typically used in composite controls, which are controls that use child controls for some or all their functionality. The Control.EnsureChildControls method is called in order to make sure that child controls have been created and are ready to process input, to perform data binding, or to perform other tasks.

The System.Web.UI.WebControls.GridView control is an example of a composite control. It creates child controls such as System.Web.UI.WebControls.Table, System.Web.UI.WebControls.TableRow, System.Web.UI.WebControls.TableCell, System.Web.UI.WebControls.Label, and System.Web.UI.WebControls.TextBox controls, which are used to render the HTML table that the System.Web.UI.WebControls.GridView generates.

In most cases, custom server control developers do not have to override this method. If you do override this method, use it in a way similar to the default behavior.

Requirements

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