summaryrefslogtreecommitdiff
path: root/demos/quickstart/protected/pages/Fundamentals/Controls.page
diff options
context:
space:
mode:
authorxue <>2005-12-27 01:20:17 +0000
committerxue <>2005-12-27 01:20:17 +0000
commit1db22ed3a9bb223a4bb83b46537b03b8866e3650 (patch)
tree6d7d6fa5364549b2e72312c4ee5c0a65edf34fdd /demos/quickstart/protected/pages/Fundamentals/Controls.page
parent28fa4ab2490f518f4d0469c87e63addfe7dbbc8e (diff)
Diffstat (limited to 'demos/quickstart/protected/pages/Fundamentals/Controls.page')
-rw-r--r--demos/quickstart/protected/pages/Fundamentals/Controls.page38
1 files changed, 35 insertions, 3 deletions
diff --git a/demos/quickstart/protected/pages/Fundamentals/Controls.page b/demos/quickstart/protected/pages/Fundamentals/Controls.page
index 7703003d..6c45acf1 100644
--- a/demos/quickstart/protected/pages/Fundamentals/Controls.page
+++ b/demos/quickstart/protected/pages/Fundamentals/Controls.page
@@ -4,16 +4,48 @@
A control is an instance of class <code>TControl</code> or its subclass. A control is a component defined in addition with user interface. The base class <code>TControl</code> defines the parent-child relationship among controls which reflects the containment relationship among user interface elements.
</p>
-<h3>Parent-Child Relationship</h3>
+<h2>Control Tree</h2>
<p>
-A parent control is in charge of the state transition of its child controls. The rendering result of the child controls are usually used to compose the parent control's presentation.
+Controls are related to each other via parent-child relationship. Each parent control can have one or several child controls. A parent control is in charge of the state transition of its child controls. The rendering result of the child controls are usually used to compose the parent control's presentation. The parent-child relationship brings together controls into a control tree. A page is at the root of the tree, whose presentation is returned to the end-users.
</p>
<p>
-The parent-child relationship is usually established by the framework via <a href="?page=Configurations.Templates1">templates</a>. In code, you may explicitly specify a control as a child of another using the following method,
+The parent-child relationship is usually established by the framework via <a href="?page=Configurations.Templates1">templates</a>. In code, you may explicitly specify a control as a child of another using one of the following methods,
<pre class="source">
$parent->Controls->add($child);
+$parent->Controls[]=$child;
</pre>
where the property <code>Controls</code> refers to the child control collection of the parent.
</p>
+<h2>Control Identification</h2>
+<p>
+Each control has an <code>ID</code> property that can be uniquely identify itself among its sibling controls. In addition, each control has a <code>UniqueID</code> and a <code>ClientID</code> which can be used to globally identify the control in the tree that the control resides in. <code>UniqueID</code> and <code>ClientID</code> are very similar. The former is used by the framework to determine the location of the corresponding control in the tree, while the latter is mainly used on the client side as HTML tag IDs. In general, you should not rely on the explicit format of <code>UniqueID</code> or <code>ClientID</code>.
+</p>
+
+<h2>Naming Containers</h2>
+<p>
+Each control has a naming container which is a control creating a unique namespace for differentiating between controls with the same <code>ID</code>. For example, a <code>TRepeater</code> control creates multiple items each having child controls with the same <code>ID</code>s. To differentiate these child controls, each item serves as a naming container. Therefore, a child control may be uniquely identified using its naming container's <code>ID</code> together with its own <code>ID</code>. As you may already have understood, <code>UniqueID</code> and <code>ClientID</code> rely on the naming containers.
+</p>
+<p>
+A control can serve as a naming container if it implements the <code>INamingContainer</code> interface.
+</p>
+
+<h2>ViewState and ControlState</h2>
+<p>
+HTTP is a stateless protocol, meaning it does not provide functionality to support continuing interaction between a user and a server. Each request is considered as discrete and independent of each other. A Web application, however, often needs to know what a user has done in previous requests. People thus introduce sessions to help remember such state information.
+</p>
+<p>
+PRADO borrows the viewstate and controlstate concept from Microsoft ASP.NET to provides additional stateful programming mechanism. A value storing in viewstate or controlstate may be available to the next requests if the new requests are form submissions (called postback) to the same page by the same user. The difference between viewstate and controlstate is that the former can be disabled while the latter cannot.
+</p>
+<p>
+Viewstate and controlstate are implemented in <code>TControl</code>. They are commonly used to define various properties of controls. To save and retrieve values from viewstate or controlstate, use following methods,
+<pre class="source">
+$this-&gt;getViewState('Name',$defaultValue);
+$this-&gt;setViewState('Name',$value,$defaultValue);
+$this-&gt;getControlState('Name',$defaultValue);
+$this-&gt;setControlState('Name',$value,$defaultValue);
+</pre>
+where <code>$this</code> refers to the control instance, <code>Name</code> refers to a key identifying the persistent value, <code>$defaultValue</code> is optional. When retrieving values from viewstate or controlstate, if the corresponding key does not exist, the default value will be returned.
+</p>
+
</com:TContent> \ No newline at end of file