summaryrefslogtreecommitdiff
path: root/demos/quickstart/protected/pages/Fundamentals/HelloWorld.page
blob: 572c6766685bd35b8ed24b1b2bf3abed6cfc7285 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
<com:TContent ID="body" >
<h1>Sample: Hello World</h1>
<p>
"Hello World" perhaps is the simplest <i>interactive</i> PRADO application that you can build. It displays to end-users a page with a submit button whose caption is <i>Click Me</i>. When the user clicks on the button, the button changes the caption to <i>Hello World</i>.
</p>
<p>
There are many approaches that can achieve the above goal. One can submit the page to the server, examine the POST variable, and generate a new page with the button caption updated. Or one can simply use JavaScript to update the button caption upon its <i>onclick</i> event.
</p>
<p>
PRADO promotes component-based and event-driven Web programming. The button is represented by a <i>TButton</i> object. It encapsulates the button caption as the <i>Text</i> property and associates the user button click action with a server-side <i>Click</i> event. Therefore, the "Hello World" task can be handled intuitively and easily. One simply needs to attach a function to the button's <i>Click</i> event. Within the function, the button's <i>Text</i> property is modified as "Hello World". The following diagram shows the above sequence,
</p>
<img src="<%~Samples/HelloWorld/sequence.gif%>" />
<p>
The code that a developer needs to write is merely the following event handler function, where <tt>$sender</tt> refers to the button object.
<com:TTextHighlighter CssClass="source">
public function buttonClicked($sender,$param)
{
	$sender->Text = "Hello World";
}
</com:TTextHighlighter>
</p>
<p>
The following line in the page template attaches the <tt>buttonClicked()</tt> method to the <tt>OnClick</tt> event of the button,
</p>
<com:TTextHighlighter Language="prado" CssClass="source">
&lt;com:TButton Text="Click Me" OnClick="buttonClicked" /&gt;
</com:TTextHighlighter>

<com:RunBar PagePath="Fundamentals.Samples.HelloWorld.Home" />

</com:TContent>