从服务器端 (VB) 修改动画
ASP.NET AJAX 控件工具包中的动画控件不仅是一个控件,而且是一个用于向控件添加动画的整个框架。 还可以在服务器端更改动画
概述
ASP.NET AJAX 控件工具包中的动画控件不仅是一个控件,而且是一个用于向控件添加动画的整个框架。 还可以在服务器端更改动画
步骤
首先,在页面中包括 ScriptManager
;然后加载 ASP.NET AJAX 库,从而可以使用 Control Toolkit:
<asp:ScriptManager ID="asm" runat="server" />
动画将应用于如下所示的文本面板:
<asp:Panel ID="panelShadow" runat="server" CssClass="panelClass">
ASP.NET AJAX is a free framework for quickly creating a new generation of more
efficient, more interactive and highly-personalized Web experiences that work
across all the most popular browsers.<br />
ASP.NET AJAX is a free framework for quickly creating a new generation of more
efficient, more interactive and highly-personalized Web experiences that work
across all the most popular browsers.<br />
ASP.NET AJAX is a free framework for quickly creating a new generation of more
efficient, more interactive and highly-personalized Web experiences that work
across all the most popular browsers.<br />
</asp:Panel>
在面板的关联 CSS 类中,定义漂亮的背景色,并为面板设置固定宽度:
<style type="text/css">
.panelClass {background-color: lime; width: 300px;}
</style>
其余代码在服务器端运行,不使用标记;相反,它使用代码创建 AnimationExtender
控件:
<script runat="server">
Sub Page_Load()
Dim ae As New AjaxControlToolkit.AnimationExtender()
ae.TargetControlID = "Panel1"
但是,Control Toolkit 当前不提供 API 访问权限来创建单个动画。 但是,可以将 的 Animations 属性设置为 AnimationExtender
包含以声明方式分配动画时使用的 XML 标记的字符串。 若要创建不能包含 元素的 <Animations>
XML,可以使用.NET Framework的 XML 支持,或者,如以下代码所示,只需提供 字符串:
ae.Animations = "<OnLoad><Parallel><FadeOut Duration=""1.5""
Fps=""24"" /><Resize Width=""1000""
Height=""150"" Unit=""px"" /></Parallel></OnLoad>"
最后,在 AnimationExtender
元素内 <form runat="server">
将 控件添加到当前页,确保包含动画并运行:
form1.Controls.Add(ae)
End Sub
</script>
动画是使用服务器端 C#/VB 代码创建的 (单击以查看全尺寸图像)