AJAX ControlToolkit学习日志-UpdatePanelAnimationExtender(30)

         UpdatePanelAnimationExtender控件用于在UpdatePanel发生更新时,产生动画效果。

下面来看一个示例:

1)在VS2005中新建一个ASP.NET AJAX-Enabled Web Project项目工程,命名为UpdatePanelAnimationExtender1。

2)在页面上拖放一个UpdatePanel,在其里拖放一个Label用于显示时间。然后再拖放3个CheckBox,用于设置不同的动画效果。

代码如下:

 1None.gif    <div id="up1" style="background-color: #40669A;">
 2None.gif        <asp:UpdatePanel ID="UpdatePanel1" runat="server">
 3None.gif            <ContentTemplate>
 4None.gif                <asp:Label ID="Label1" runat="server" Text=""></asp:Label>
 5None.gif            </ContentTemplate>
 6None.gif            <Triggers>
 7None.gif                <asp:AsyncPostBackTrigger ControlID="btnUpdate" />
 8None.gif            </Triggers>
 9None.gif        </asp:UpdatePanel>
10None.gif        &nbsp;</div>
11None.gif        <div>
12None.gif        Choose the effects, then press 'Update':<br />
13None.gif        <input type="checkbox" id="effect_fade" checked="checked" /><label for="effect_fade">Fade</label><br />
14None.gif        <input type="checkbox" id="effect_collapse" checked="checked" /><label for="effect_collapse">Collapse</label><br />
15None.gif        <input type="checkbox" id="effect_color" checked="checked" /><label for="effect_color">Color Background</label><br />
16None.gif        <asp:Button ID="btnUpdate" runat="server" Text="Update" OnClick="btnUpdate_Click" />
17None.gif        </div>

3)然后在页面上拖放一个UpdatePanelAnimationExtender,用于控制动画效果。

代码如下:
        <cc1:UpdatePanelAnimationExtender ID="UpdatePanelAnimationExtender1" BehaviorID="animation" runat="server" TargetControlID="UpdatePanel1">
            <Animations>
                <OnUpdating>
                    <Sequence>
                        <%-- Store the original height of the panel --%>
                        <ScriptAction Script="var b = $find('animation'); b._originalHeight = b._element.offsetHeight;" />
                        <%-- Disable all the controls --%>
                        <Parallel duration="0">
                            <EnableAction AnimationTarget="btnUpdate" Enabled="false" />
                            <EnableAction AnimationTarget="effect_color" Enabled="false" />
                            <EnableAction AnimationTarget="effect_collapse" Enabled="false" />
                            <EnableAction AnimationTarget="effect_fade" Enabled="false" />
                        </Parallel>
                        <StyleAction Attribute="overflow" Value="hidden" />
                        <%-- Do each of the selected effects --%>
                        <Parallel duration=".25" Fps="30">
                            <Condition ConditionScript="$get('effect_fade').checked">
                                <FadeOut AnimationTarget="up_container" minimumOpacity=".2" />
                            </Condition>
                            <Condition ConditionScript="$get('effect_collapse').checked">
                                <Resize Height="0" />
                            </Condition>
                            <Condition ConditionScript="$get('effect_color').checked">
                                <Color AnimationTarget="up_container" PropertyKey="backgroundColor"
                                    EndValue="#FF0000" StartValue="#40669A" />
                            </Condition>
                        </Parallel>
                    </Sequence>
                </OnUpdating>
                <OnUpdated>
                    <Sequence>
                        <%-- Do each of the selected effects --%>
                        <Parallel duration=".25" Fps="30">
                            <Condition ConditionScript="$get('effect_fade').checked">
                                <FadeIn AnimationTarget="up_container" minimumOpacity=".2" />
                            </Condition>
                            <Condition ConditionScript="$get('effect_collapse').checked">
                                <%-- Get the stored height --%>
                                <Resize HeightScript="$find('animation')._originalHeight" />
                            </Condition>
                            <Condition ConditionScript="$get('effect_color').checked">
                                <Color AnimationTarget="up_container" PropertyKey="backgroundColor"
                                    StartValue="#FF0000" EndValue="#40669A" />
                            </Condition>
                        </Parallel>
                        <%-- Enable all the controls --%>
                        <Parallel duration="0">
                            <EnableAction AnimationTarget="effect_fade" Enabled="true" />
                            <EnableAction AnimationTarget="effect_collapse" Enabled="true" />
                            <EnableAction AnimationTarget="effect_color" Enabled="true" />
                            <EnableAction AnimationTarget="btnUpdate" Enabled="true" />
                        </Parallel>                           
                    </Sequence>
                </OnUpdated>
            </Animations>
        </cc1:UpdatePanelAnimationExtender>
4)对Page_load和"btnUpdate"按钮添加事件处理。
代码如下:
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                this.Label1.Text = DateTime.Now.ToString();
            }
        }

        protected void btnUpdate_Click(object sender, EventArgs e)
        {
            this.Label1.Text = DateTime.Now.ToString();
        }
5)按下CTRL+F5,在浏览器中查看效果。
效果图如下:

转载于:https://www.cnblogs.com/qc1984326/archive/2007/03/23/684750.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值