TControl is the base class for all components on a page hierarchy.
It implements the following features for UI-related functionalities:
- databinding feature
- parent and child relationship
- naming container and containee relationship
- viewstate and controlstate features
- rendering scheme
- control lifecycles
A property can be data-bound with an expression. By calling {@link dataBind},
expressions bound to properties will be evaluated and the results will be
set to the corresponding properties.
Parent and child relationship determines how the presentation of controls are
enclosed within each other. A parent will determine where to place
the presentation of its child controls. For example, a TPanel will enclose
all its child controls' presentation within a div html tag. A control's parent
can be obtained via {@link getParent Parent} property, and its
{@link getControls Controls} property returns a list of the control's children,
including controls and static texts. The property can be manipulated
like an array for adding or removing a child (see {@link TList} for more details).
A naming container control implements INamingContainer and ensures that
its containee controls can be differentiated by their ID property values.
Naming container and containee realtionship specifies a protocol to uniquely
identify an arbitrary control on a page hierarchy by an ID path (concatenation
of all naming containers' IDs and the target control's ID).
Viewstate and controlstate are two approaches to preserve state across
page postback requests. ViewState is mainly related with UI specific state
and can be disabled if not needed. ControlState represents crucial logic state
and cannot be disabled.
A control is rendered via its {@link render()} method (the method is invoked
by the framework.) Descendant control classes may override this method for
customized rendering. By default, {@link render()} invokes {@link renderChildren()}
which is responsible for rendering of children of the control.
Control's {@link getVisible Visible} property governs whether the control
should be rendered or not.
Each control on a page will undergo a series of lifecycles, including
control construction, Init, Load, PreRender, Render, and OnUnload.
They work together with page lifecycles to process a page request.