From f4de82bcdafba51e4eed9cae6b2d3e5375ffd115 Mon Sep 17 00:00:00 2001 From: xue <> Date: Tue, 9 May 2006 12:11:38 +0000 Subject: --- .../protected/pages/Controls/NewControl.page | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'demos/quickstart/protected/pages/Controls/NewControl.page') diff --git a/demos/quickstart/protected/pages/Controls/NewControl.page b/demos/quickstart/protected/pages/Controls/NewControl.page index 51d0cc02..8f4b9be9 100644 --- a/demos/quickstart/protected/pages/Controls/NewControl.page +++ b/demos/quickstart/protected/pages/Controls/NewControl.page @@ -1,6 +1,6 @@ -

Writing New Controls

+

Writing New Controls

Writing new controls is often desired by advanced programmers, because they want to reuse the code that they write for dealing with complex presentation and user interactions.

@@ -8,7 +8,7 @@ Writing new controls is often desired by advanced programmers, because they want In general, there are two ways of writing new controls: composition of existing controls and extending existing controls. They all require that the new control inherit from TControl or its child classes.

-

Composition of Existing Controls

+

Composition of Existing Controls

Composition is the easiest way of creating new controls. It mainly involves instantiating existing controls, configuring them and making them the constituent components. The properties of the constituent components are exposed through subproperties.

@@ -19,7 +19,7 @@ One can compose a new control in two ways. One is to extend TCompositeContro As an example, we show how to create a labeled textbox called LabeledTextBox using the above two approaches. A labeled textbox displays a label besides a textbox. We want reuse the PRADO provided TLabel and TTextBox to accomplish this task.

-

Composition by Writing Templates

+

Composition by Writing Templates

We need two files: a control class file named LabeledTextBox.php and a control template file named LabeledTextBox.tpl. Both must reside under the same directory.

@@ -46,7 +46,7 @@ In the above, the method call to ensureChildControls() ensures that bot

-

Composition by Overriding createChildControls()

+

Composition by Overriding createChildControls()

For a composite control as simple as LabeledTextBox, it is better to create it by extending TCompositeControl and overriding the createChildControls() method, because it does not use templates and thus saves template parsing time.

@@ -80,7 +80,7 @@ class LabeledTextBox extends TCompositeControl { -

Using LabeledTextBox

+

Using LabeledTextBox

To use LabeledTextBox control, first we need to include the corresponding class file. Then in a page template, we can write lines like the following,

@@ -91,7 +91,7 @@ To use LabeledTextBox control, first we need to include the correspondi In the above, Label.Text is a subproperty of LabeledTextBox, which refers to the Text property of the Label property. For other details of using LabeledTextBox, see the above online examples.

-

Extending Existing Controls

+

Extending Existing Controls

Extending existing controls is the same as conventional class inheritance. It allows developers to customize existing control classes by overriding their properties, methods, events, or creating new ones.

@@ -102,7 +102,7 @@ The difficulty of the task depends on how much an existing class needs to be cus In this section, we mainly introduce the base control classes TControl and TWebControl, showing how they can be customized. We also introduce how to write controls with specific functionalities, such as loading post data, raising post data and databinding with data source.

-

Extending TControl

+

Extending TControl

TControl is the base class of all control classes. Two methods are of the most importance for derived control classes:

@@ -125,7 +125,7 @@ Other important properties and methods include:
  • Control lifecycles - Life page lifecycles, controls also have lifecycles. Each control undergoes the following lifecycles in order: constructor, onInit(), onLoad(), onPreRender(), render(), and onUnload. More details can be found in the page section.
  • -

    Extending TWebControl

    +

    Extending TWebControl

    TWebControl is mainly used as a base class for controls representing HTML elements. It provides a set of properties that are common among HTML elements. It breaks the TControl::render() into the following methods that are more suitable for rendering an HTML element:

    @@ -139,7 +139,7 @@ Other important properties and methods include: When rendering the openning HTML tag, TWebControl calls getTagName() to obtain the tag name. Derived classes may override this method to render different tag names.

    -

    Creating Controls with Special Functionalities

    +

    Creating Controls with Special Functionalities

    If a control wants to respond to client-side events and translate them into server side events (called postback events), such as TButton, it has to implement the IPostBackEventHandler interface.

    -- cgit v1.2.3