| 1 |
lars |
1 |
<com:TContent ID="body">
|
|
|
2 |
<!-- $Id: ActiveButton.page 1817 2007-03-31 23:36:00Z wei $ -->
|
|
|
3 |
<h1 id="122026">TActiveButton</h1>
|
|
|
4 |
<com:DocLink ClassPath="System.Web.UI.ActiveControls.TActiveButton" />
|
|
|
5 |
|
|
|
6 |
<p id="610410" class="block-content"><tt>TActiveButton</tt> is the active control counter part to
|
|
|
7 |
<a href="?page=Controls.Button">TButton</a>.
|
|
|
8 |
When a <tt>TActiveButton</tt> is clicked, rather than a normal post back request a
|
|
|
9 |
callback request is initiated. The <tt>OnCallback</tt> event is raised
|
|
|
10 |
during a callback request and it is raise <strong>after</strong>
|
|
|
11 |
the <tt>OnClick</tt> event.
|
|
|
12 |
</p>
|
|
|
13 |
|
|
|
14 |
<p id="610411" class="block-content">When the <tt>ActiveControl.EnableUpdate</tt> property is true,
|
|
|
15 |
changing the <tt>Text</tt> property during a callback request will update
|
|
|
16 |
the button's caption on the client-side.</p>
|
|
|
17 |
|
|
|
18 |
<p id="610412" class="block-content">Since the <tt>OnCallback</tt> event is raised only during a callback request,
|
|
|
19 |
the <tt>OnCallback</tt> event handler can be used to handle logic specifically
|
|
|
20 |
related to callback requests. The <tt>OnClick</tt> event handler is raised
|
|
|
21 |
when ever the button is clicked, even if javascript is disabled.</p>
|
|
|
22 |
|
|
|
23 |
<p id="610413" class="block-content">The following example the use of both the <tt>OnClick</tt> and <tt>OnCallback</tt>
|
|
|
24 |
events of an <tt>TActiveButton</tt>.</p>
|
|
|
25 |
|
|
|
26 |
<com:RunBar PagePath="ActiveControls.Samples.TActiveButton.Home" />
|
|
|
27 |
|
|
|
28 |
<h2 id="122027">TActiveButton Class Diagram</h2>
|
|
|
29 |
<p id="610414" class="block-content">The class diagram for <tt>TActiveButton</tt> is illustrated in the figure below.
|
|
|
30 |
Most active control that can perform callback request have a similar structure.
|
|
|
31 |
</p>
|
|
|
32 |
|
|
|
33 |
<img src=<%~ TActiveButtonClass.png %> class="figure"
|
|
|
34 |
alt="TActiveButton class diagram" title="TActiveButton class diagram" />
|
|
|
35 |
|
|
|
36 |
<p id="610415" class="block-content"><tt>TActiveButton</tt> is an extension of <a href="?page=Controls.Button">TButton</a>
|
|
|
37 |
and implements two additional interfaces <tt>ICallbackEventHandler</tt> and
|
|
|
38 |
<tt>IActiveControl</tt>. The <tt>TActiveButton</tt> contains an instance of
|
|
|
39 |
<a href="?page=ActiveControls.BaseActiveControl">TBaseActiveCallbackControl</a>
|
|
|
40 |
available through the <tt>ActiveControl</tt> property of <tt>TActiveButton</tt>.
|
|
|
41 |
The following example set the callback parameter of the <tt>TActiveButton</tt> when
|
|
|
42 |
a callback request is dispatched.
|
|
|
43 |
</p>
|
|
|
44 |
<com:TTextHighlighter Language="prado" CssClass="source block-content" id="code1">
|
|
|
45 |
<com:TActiveButton
|
|
|
46 |
Text="Click Me"
|
|
|
47 |
OnCallback="button_callback"
|
|
|
48 |
ActiveControl.CallbackParameter="value" />
|
|
|
49 |
</com:TTextHighlighter>
|
|
|
50 |
<p id="610416" class="block-content">In the <tt>OnCallback</tt> event handler method, the <tt>CallbackParameter</tt>
|
|
|
51 |
is available in the <tt>$param</tt> object.</p>
|
|
|
52 |
<com:TTextHighlighter Language="php" CssClass="source block-content" id="code2">
|
|
|
53 |
public function button_callback($sender, $param)
|
|
|
54 |
{
|
|
|
55 |
echo $param->CallbackParameter; //outputs "value"
|
|
|
56 |
}
|
|
|
57 |
</com:TTextHighlighter>
|
|
|
58 |
|
|
|
59 |
<h2 id="122028">Adding Client Side Behaviour</h2>
|
|
|
60 |
|
|
|
61 |
<p id="610417" class="block-content">With in the <tt>ActiveControl</tt> property is an instance of
|
|
|
62 |
<a href="?page=ActiveControls.CallbackClientSide">TCallbackClientSide</a> available
|
|
|
63 |
as a property <tt>ClientSide</tt> of <tt>TActiveButton</tt>.
|
|
|
64 |
The <tt>ClientSide</tt> property contains sub-properties, such as <tt>RequestTimeOut</tt>,
|
|
|
65 |
and client-side javascript event handler, such as <tt>OnLoading</tt>,
|
|
|
66 |
that are used by the client-side when making a callback request.
|
|
|
67 |
The following example demonstrates the toggling of a "loading" indicator
|
|
|
68 |
when the client-side is making a callback request.
|
|
|
69 |
</p>
|
|
|
70 |
|
|
|
71 |
<com:TTextHighlighter Language="prado" CssClass="source block-content" id="code3">
|
|
|
72 |
<com:TClientScript PradoScripts="effects" />
|
|
|
73 |
<span id="callback_status">Loading...</span>
|
|
|
74 |
|
|
|
75 |
<com:TActiveButton
|
|
|
76 |
Text="Click Me"
|
|
|
77 |
OnCallback="button_callback"
|
|
|
78 |
ActiveControl.CallbackParameter="value" >
|
|
|
79 |
<prop:ClientSide
|
|
|
80 |
OnLoading="Element.show('callback_status')"
|
|
|
81 |
OnComplete="Element.hide('callback_status')" />
|
|
|
82 |
</com:TActiveButton>
|
|
|
83 |
</com:TTextHighlighter>
|
|
|
84 |
|
|
|
85 |
<p id="610418" class="block-content">The example loads the "effects" javascript library using the
|
|
|
86 |
<a href="?page=Controls.ClientScript">TClientScript</a> component.
|
|
|
87 |
The <tt>ClientSide.OnLoading</tt> property value contains
|
|
|
88 |
javascript statement that uses the "effects" library to show the "Loading..."
|
|
|
89 |
span tag. Similarly, <tt>ClientSide.OnComplete</tt> property
|
|
|
90 |
value contains the javascript statement that hides the "Loading..." span tag.
|
|
|
91 |
See <a href="?page=ActiveControls.CallbackClientSide">TCallbackClientSide</a> for
|
|
|
92 |
further details on client-side property details.
|
|
|
93 |
</p>
|
|
|
94 |
<div class="last-modified">$Id: ActiveButton.page 1817 2007-03-31 23:36:00Z wei $</div></com:TContent>
|