Animating an UpdatePanel Control (C#)
The Animation control in the ASP.NET AJAX Control Toolkit is not just a control but a whole framework to add animations to a control. For the contents of an UpdatePanel, a special extender exists that relies heavily on the animation framework: UpdatePanelAnimation. This tutorial shows how to set up such an animation for an UpdatePanel.
Overview
The Animation control in the ASP.NET AJAX Control Toolkit is not just a control but a whole framework to add animations to a control. For the contents of an UpdatePanel
, a special extender exists that relies heavily on the animation framework: UpdatePanelAnimation
. This tutorial shows how to set up such an animation for an UpdatePanel
.
Steps
The first step is as usual to include the ScriptManager
in the page so that the ASP.NET AJAX library is loaded and the Control Toolkit can be used:
[!code-aspxMain]
1: <asp:ScriptManager ID="asm" runat="server" />
The animation in this scenario will be applied to an ASP.NET Wizard
web control residing in an UpdatePanel
. Three (arbitrary) steps provide enough options to trigger postbacks:
[!code-aspxMain]
1: <asp:UpdatePanel ID="UpdatePanel1" runat="server">
2: <ContentTemplate>
3: <asp:Wizard ID="Wizard1" runat="server">
4: <WizardSteps>
5: <asp:WizardStep runat="server" StepType="Start" Title="Ready!">
6: </asp:WizardStep>
7: <asp:WizardStep runat="server" StepType="Step" Title="Set!">
8: </asp:WizardStep>
9: <asp:WizardStep runat="server" StepType="Finish" Title="Go!">
10: </asp:WizardStep>
11: </WizardSteps>
12: </asp:Wizard>
13: </ContentTemplate>
14: </asp:UpdatePanel>
The markup necessary for the UpdatePanelAnimationExtender
control is quite similar to the markup used for the AnimationExtender
. In the TargetControlID
attribute we provide the ID
of the UpdatePanel
to animate; within the UpdatePanelAnimationExtender
control, the <Animations>
element holds XML markup for the animation(s). However there is one difference: The amount of events and event handlers is limited in comparison to AnimationExtender
. For UpdatePanels
, only two of them exist:
<OnUpdated>
when the UpdatePanel has been updated<OnUpdating>
when the UpdatePanel starts updating
In this scenario, the new content of the UpdatePanel
(after the postback) shall fade in. This is the necessary markup for that:
[!code-aspxMain]
1: <ajaxToolkit:UpdatePanelAnimationExtender ID="upae" runat="server"
2: TargetControlID="UpdatePanel1">
3: <Animations>
4: <OnUpdated>
5: <FadeIn Duration="1.0" Fps="24" />
6: </OnUpdated>
7: </Animations>
8: </ajaxToolkit:UpdatePanelAnimationExtender>
Now whenever a postback occurs within the UpdatePanel, the new contents of the panel fade in smoothly.
The next wizard step is fading in (Click to view full-size image)
|