TControl class
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
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 Parent property, and its 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 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 render() method (the method is invoked by the framework.) Descendant control classes may override this method for customized rendering. By default, render() invokes renderChildren() which is responsible for rendering of children of the control. Control's 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.
| Method Summary |
|
void
|
Adds a control into the child collection of the control.
|
|
void
|
Adds the object instantiated on a template to the child control collection.
|
|
protected
void
|
Add controls implementing IPostBackDataHandler to post data loaders.
|
|
void
|
Applies a stylesheet skin to a control.
|
|
void
|
Sets up the binding between a property (or property path) and an expression.
|
|
protected
void
|
Auto databinding properties of the control.
|
|
void
|
Sets up the binding between a property (or property path) and an expression.
|
|
void
|
Broadcasts an event.
|
|
boolean
|
This method responds to a bubbled event.
|
|
protected
void
|
Clears up the child state data.
|
|
protected
void
|
Clears a controlstate value.
|
|
void
|
Resets the control as a naming container.
|
|
void
|
Clears a viewstate value.
|
|
string
|
Converts a unique ID to a client ID.
|
|
void
|
Creates child controls.
|
|
protected
TControlCollection
|
Creates a control collection object that is to be used to hold child controls
|
|
void
|
Performs the databinding for this control.
|
|
protected
void
|
Databinding child controls.
|
|
protected
void
|
Databinding properties of the control.
|
|
void
|
Ensures child controls are created.
|
|
TControl|null
|
Finds a control by ID path within the current naming container.
|
|
array
|
Finds all child and grand-child controls with the specified ID.
|
|
array
|
Finds all child and grand-child controls that are of the specified type.
|
|
void
|
Sets input focus to this control.
|
|
TControlAdapter
|
|
|
boolean
|
|
|
string
|
|
|
TAttributeCollection
|
Returns the list of custom attributes.
|
|
protected
boolean
|
|
|
string
|
Returns the client ID of the control.
|
|
TControlCollection
|
|
|
protected
integer
|
Gets the lifecycle step the control is currently at.
|
|
protected
mixed
|
Returns a controlstate value.
|
|
mixed
|
Returns custom data associated with this control.
|
|
boolean
|
Returns a value indicating whether the control is enabled.
|
|
boolean
|
|
|
boolean
|
|
|
boolean
|
|
|
boolean
|
|
|
boolean
|
|
|
boolean
|
|
|
boolean
|
|
|
boolean
|
|
|
boolean
|
|
|
boolean
|
|
|
string
|
getID
( boolean $hideAutoID)
Returns the id of the control.
|
|
TControl
|
|
|
TPage
|
|
|
TControl
|
|
|
mixed
|
Returns the named registered object.
|
|
string
|
|
|
TTemplateControl
|
|
|
TTemplateControl
|
|
|
string
|
Returns a unique ID that identifies the control in the page hierarchy.
|
|
mixed
|
Returns a viewstate value.
|
|
boolean
|
Checks if a control is visible.
|
|
boolean
|
|
|
protected
void
|
Performs the Init step for the control and all its child controls.
|
|
protected
boolean
|
|
|
boolean
|
|
|
protected
void
|
Performs the Load step for the control and all its child controls.
|
|
void
|
This method is invoked right after the control has loaded its state.
|
|
protected
void
|
Loads state (viewstate and controlstate) into a control and its children.
|
|
void
|
Raises 'OnDataBinding' event.
|
|
void
|
This method is invoked when the control enters 'OnInit' stage.
|
|
void
|
This method is invoked when the control enters 'OnLoad' stage.
|
|
void
|
This method is invoked when the control enters 'OnPreRender' stage.
|
|
void
|
This method is invoked when the control enters 'OnUnload' stage.
|
|
protected
void
|
Performs the PreRender step for the control and all its child controls.
|
|
protected
void
|
Invokes the parent's bubbleEvent method.
|
|
void
|
Registers an object by a name.
|
|
string
|
Removes the named attribute.
|
|
void
|
Removes a control from the child collection of the control.
|
|
void
|
Renders the control.
|
|
void
|
Renders the children of the control.
|
|
void
|
Renders the control.
|
|
void
|
This method is invoked when control state is to be saved.
|
|
protected
array
|
Saves all control state (viewstate and controlstate) as a collection.
|
|
void
|
|
|
void
|
Sets a custom control attribute.
|
|
protected
void
|
Sets a value indicating whether child controls are created.
|
|
protected
void
|
Sets the lifecycle step the control is currently at.
|
|
protected
void
|
Sets a controlstate value.
|
|
void
|
Associates custom data with this control.
|
|
void
|
|
|
void
|
|
|
void
|
|
|
void
|
|
|
void
|
Sets the page for a control.
|
|
void
|
|
|
void
|
Sets the control whose template contains this control.
|
|
void
|
setViewState
( string $key, mixed $value, mixed $defaultValue)
Sets a viewstate value.
|
|
void
|
|
|
void
|
Sets a value indicating whether we should keep data in viewstate.
|
|
protected
void
|
Traverse the whole control hierarchy rooted at this control.
|
|
void
|
Breaks the binding between a property (or property path) and an expression.
|
|
protected
void
|
Performs the Unload step for the control and all its child controls.
|
|
void
|
Unregisters an object by name.
|
|
mixed
|
Returns a property value by name or a control by ID.
|
| Method Details |
addedControl
| public void addedControl |
(TControl $control ) |
Adds a control into the child collection of the control.
Control lifecycles will be caught up during the addition. Only framework developers should use this method.
| Input |
| TControl | $control | the new child control |
| Output |
| Exception |
|
addParsedObject
| public void addParsedObject |
(string|TComponent $object ) |
Adds the object instantiated on a template to the child control collection.
This method overrides the parent implementation. Only framework developers and control developers should use this method.
| Input |
| string|TComponent | $object | text string or component parsed and instantiated in template |
| Output |
| Exception |
|
addToPostDataLoader
| protected void addToPostDataLoader |
() |
Add controls implementing IPostBackDataHandler to post data loaders.
|
applyStyleSheetSkin
| public void applyStyleSheetSkin |
(TPage $page ) |
Applies a stylesheet skin to a control.
| Input |
| TPage | $page | the page containing the control |
| Output |
| Exception |
| throws | TInvalidOperationException if the stylesheet skin is applied already |
|
autoBindProperty
| public void autoBindProperty |
(string $name , string $expression ) |
Sets up the binding between a property (or property path) and an expression.
Unlike regular databinding, the expression bound by this method is automatically evaluated during prerenderRecursive(). The context of the expression is the template control (or the control itself if it is a page).
| Input |
| string | $name | the property name, or property path |
| string | $expression | the expression |
| Output |
| Exception |
|
autoDataBindProperties
| protected void autoDataBindProperties |
() |
Auto databinding properties of the control.
|
bindProperty
| public void bindProperty |
(string $name , string $expression ) |
Sets up the binding between a property (or property path) and an expression.
The context of the expression is the template control (or the control itself if it is a page).
| Input |
| string | $name | the property name, or property path |
| string | $expression | the expression |
| Output |
| Exception |
|
broadcastEvent
Broadcasts an event.
The event will be sent to all controls on the current page hierarchy. If a control defines the event, the event will be raised for the control. If a control implements IBroadcastEventReceiver, its IBroadcastEventReceiver::broadcastEventReceived method will be invoked which gives the control a chance to respond to the event. For example, when broadcasting event 'OnClick', all controls having 'OnClick' event will have this event raised, and all controls implementing IBroadcastEventReceiver will also have its IBroadcastEventReceiver::broadcastEventReceived invoked.
| Input |
| string | $name | name of the broadcast event |
| TControl | $sender | sender of this event |
| TEventParameter | $param | event parameter |
| Output |
| Exception |
|
bubbleEvent
This method responds to a bubbled event.
This method should be overriden to provide customized response to a bubbled event. Check the type of event parameter to determine what event is bubbled currently.
| Input |
| TControl | $sender | sender of the event |
| TEventParameter | $param | event parameters |
| Output |
|
boolean
| true if the event bubbling is handled and no more bubbling. |
| Exception |
|
clearChildState
| protected void clearChildState |
() |
Clears up the child state data.
After a control loads its state, those state that do not belong to any existing child controls are stored as child state. This method will remove these state. Only frameworker developers and control developers should use this method.
|
clearControlState
| protected void clearControlState |
(string $key ) |
Clears a controlstate value.
| Input |
| string | $key | the name of the controlstate value to be cleared |
| Output |
| Exception |
|
clearNamingContainer
| public void clearNamingContainer |
() |
Resets the control as a naming container.
Only framework developers should use this method.
|
clearViewState
| public void clearViewState |
(string $key ) |
Clears a viewstate value.
| Input |
| string | $key | the name of the viewstate value to be cleared |
| Output |
| Exception |
|
convertUniqueIdToClientId
| public string convertUniqueIdToClientId |
(string $uniqueID ) |
Converts a unique ID to a client |