This is in continuation to my previous post “Moving a panel using ajax animation extender”. In this post, I have explained animating a panel on a button click.
For this we just need to make a few modifications to the earlier code.
Step 1: Add a button which will used to initiate the animation.
<asp:Button ID = "btnAnimate" runat ="server" Text="Click to Animate" OnClientClick="return false;"/>
Step 2: Change the TargetControlID to the button instead of panel.
<asp:AnimationExtender ID="AnimationExtender1" runat="server" TargetControlID ="btnAnimate" >
Step 3: Add the Sequence and EnableAction tags as following. Sequence for the panel to be animated and EnableAction for the Button to initiate the animation.
<Sequence AnimationTarget = "Panel1">
<EnableAction AnimationTarget = "btnAnimate" Enabled = "false"/>
<Move Duration=".5" FPS ="30" Vertical= "200" Horizontal = "100" unit ="px"/>
</Sequence>
Build the code and click on the button to view the animation.
You can add further sequences to this code. Suppose you want to Fadeout the panel after it is moved to the location, you can modify the above code to this.
<Sequence AnimationTarget = "Panel1">
<EnableAction AnimationTarget = "btnAnimate" Enabled = "false"/>
<Move Duration=".5" FPS ="30" Vertical= "200" Horizontal = "100" unit ="px"/>
<FadeOut Duration=".5" FPS = "30" ></FadeOut>
</Sequence>
I hope this helps.