shepherdweb.com

ASP.NET AJAX Control Toolkit AnimationExtender Using a Condition

December 12th, 2006

The ASP.NET AJAX Control Toolkit includes a control called the AnimationExtender which provides a framework for adding animation effects to web pages. One ability of the AnimationExtender is to execute code based on a condition using the Condition Animation rules. Condition Animation will “play” specific child animations based on the boolean result of the conditionScript.

Download Animation Extender Demo Code (4k .zip)

What it does…

If a checkbox is checked then the backgroundColor of the parentNode is changed to add emphasis to the checked items. The conditionScript is true causing the first child animation to play.
Animation Extender Demo - after

When a checkbox is unchecked, the backgroundColor is reset. The conditionScript returns false causing the second child animation to play.

Animation Extender Demo - before

Code Snippet…


<asp:CheckBox ID="chk1" runat="server" Text="Puppy" />
<cc1:AnimationExtender ID="AnimationExtender1" runat="server" TargetControlID="chk1">
<Animations>
<OnClick>
<Condition ConditionScript="document.getElementById('chk1').checked;">
<ScriptAction Script="document.getElementById('chk1').parentNode.style.backgroundColor = '#ADDA59';" />
<ScriptAction Script="document.getElementById('chk1').parentNode.style.backgroundColor = '#FFFFFF';" />
</Condition>
</OnClick>
</Animations>
</cc1:AnimationExtender>

kick it on DotNetKicks.com

2 Comments »

  1. DotNetKicks.com wrote,

    ASP.NET AJAX AnimationExtender Using a Condition…

    You’ve been kicked (a good thing) - Trackback from DotNetKicks.com…

    Trackback on December 12, 2006 @ 7:05 pm

  2. Matt wrote,

    How do you use the condition with a checkbox?
    Here is my code:

    but nothing happens when I click the checkbox.

    Comment on August 16, 2008 @ 4:46 pm

Leave a comment

RSS feed for comments on this post.

TrackBack URI

Bad Behavior has blocked 642 access attempts in the last 7 days.