Aug 24, 2009, 1:31 PM
Checkbox changed handler in code-behind
Hi...this seems like it ought to be simple to do (I can do it pretty easily in .net, anyway), but I'm stuck.
I have a checkbox and a textarea. The checked/unchecked state of the checkbox should control the enabled/disabled state of the textarea (and clear the textarea's content when unchecked).
I'm trying to figure out the proper way to tell the checkbox to call a function in code-behind to accomplish this. Something like:
How do I call a function in code-behind from the checkbox changed event? Do I need to use an ajaxevent and add some more plumbing to the page?
I have a checkbox and a textarea. The checked/unchecked state of the checkbox should control the enabled/disabled state of the textarea (and clear the textarea's content when unchecked).
I'm trying to figure out the proper way to tell the checkbox to call a function in code-behind to accomplish this. Something like:
<ext:Checkbox runat="server" ID="Checkbox1" BoxLabel="Toggle the textarea">
<Listener>
<Change Handler="toggleText" />
</Listener>
</ext:Checkbox>
<ext:TextArea ID="txtTest" runat="server" FieldLabel="Text Area" Enabled="false"></ext:TextArea>
and in the code-behind:protected void toggleText()
{
if (!Checkbox1.Checked)
{
txtTest.Enabled = false;
txtTest.Clear();
}
else
{
txtTest.Enabled = true;
}
}
...formgroup seems to do something similar (hides/shows a portion of the page, rather than enable/disable), but both the checkbox and textarea will be data-bound.How do I call a function in code-behind from the checkbox changed event? Do I need to use an ajaxevent and add some more plumbing to the page?