[CLOSED] Open window from checkbox
Hi Guys
Just learning ext and javascript ... i need to display an ext:window when a checkbox is "checked" (and only when it is checked, not unchecked) ... easy to do on a postback but I'd like to do it on the client.
Any assistance much appreciated.
(btw, really appreciating the Coolite tools).
RE: [CLOSED] Open window from checkbox
Hi Adrian,
You can attach a <Check> Listener to the <ext:Checkbox> to control the show/hide of a <ext:Window>.
The following code sample demonstrates.
Example
Code:
<ext:Checkbox ID="Checkbox1" runat="server">
<Listeners>
<Check Handler="(this.checked) ? Window1.show() : Window1.hide();" />
</Listeners>
</ext:Checkbox>
<ext:Window
ID="Window1"
runat="server"
Closable="false"
Title="Title"
Showonload="false"
/>
After the v0.6 release, I would suggest changing the <Check> line to the following sample.
Example
Code:
<Check Handler="(this.checked) ? #{Window1}.show() : #{Window1}.hide();" />
Wrapping the "Window1" ID with a #{} token will instruct the Toolkit to replace the #{} token with the actual .ClientID of the Control. The controls are instantiated client-side with their .ClientID's, which may be different than their server-side .ID.
Out of interest sake, I also tried the same scenario using the new <AjaxEvents> feature of v0.6. The following sample demonstrates adding a <Check> AjaxEvent to the <ext:Checkbox> which makes an ajax request/response back to the server and fires a custom "Checkbox1_Check" event.
Example
Code:
<script runat="server">
protected void Checkbox1_Check(object sender, AjaxEventArgs e)
{
if (this.Checkbox1.Checked)
{
this.Window1.Show();
}
else
{
this.Window1.Hide();
}
}
</script>
<ext:Checkbox ID="Checkbox1" runat="server">
<AjaxEvents>
<Check OnEvent="Checkbox1_Check" />
</AjaxEvents>
</ext:Checkbox>
Hope this helps.
p.s. Thanks for the feedback! much appreciated.
RE: [CLOSED] Open window from checkbox
Thanks Geoffrey ... works like a charm ... the support you're providing through this forum is brilliant.
Really looking forward to <AjaxEvents> ... its going to make working with Ext for asp.net developers - like myself - so much easier (and more powerful).