快速浏览AjaxControlToolKit控件(四)

时间:2022-02-19 16:26:38

十三.UpdatePanelAnimationExtender

主要属性:

1.TargetControlID:被更新的UpdatePanel的ID

2.OnUpdating:开始更新的时候元素的动画效果

3.OnUpdateing:结束更新后元素的效果

aspx:

快速浏览AjaxControlToolKit控件(四)快速浏览AjaxControlToolKit控件(四)Code
 <div class="demoarea">
        
<div style="margin-bottom: 10px;">
            
<div style="border: dashed 1px #222222;">
                
<div id="up_container" style="background-color: #40669A;">
                    
<asp:UpdatePanel ID="update" runat="server">
                        
<ContentTemplate>
                            
<div id="background" style="text-align: center; vertical-align: middle; line-height: 44px; padding: 12px; height: 44px; color: #FFFFFF;">
                                
<asp:Label ID="lblUpdate" runat="server" Style="padding: 5px; font-size: 14px; font-weight: bold;">
                                    
4/28/1906 12:00:00 AM
                                
</asp:Label>
                            
</div>
                        
</ContentTemplate>
                        
<Triggers>
                            
<asp:AsyncPostBackTrigger ControlID="btnUpdate" EventName="Click" />
                        
</Triggers>
                    
</asp:UpdatePanel>
                
</div>
            
</div>
        
</div>
        
        Choose the effects, then press 
'Update':<br />
        
<input type="checkbox" id="effect_fade" checked="checked" /><label for="effect_fade">Fade</label><br />
        
<input type="checkbox" id="effect_collapse" checked="checked" /><label for="effect_collapse">Collapse</label><br />
        
<input type="checkbox" id="effect_color" checked="checked" /><label for="effect_color">Color Background</label><br />
        
<asp:Button ID="btnUpdate" runat="server" Text="Update" OnClick="btnUpdate_Click" />
        
        
<ajaxToolkit:UpdatePanelAnimationExtender ID="upae" BehaviorID="animation" runat="server" TargetControlID="update">
            
<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>
        
</ajaxToolkit:UpdatePanelAnimationExtender>
    
</div>

CS:

快速浏览AjaxControlToolKit控件(四)快速浏览AjaxControlToolKit控件(四)Code
 protected void btnUpdate_Click(object sender, EventArgs e)
    {
        Thread.Sleep(
2000);
        lblUpdate.Text 
= DateTime.Now.ToString();
    }

 

快速浏览AjaxControlToolKit控件(四)

快速浏览AjaxControlToolKit控件(四)

十四.ValidatorCalloutExtender

主要属性:

1.TargetControlID:扩展的认证控件的ID

2.Width:插图的高度

3.WarningIconImageUrl:警告ICON的图片地址

4.CloseImageUrl:关闭图片的地址

快速浏览AjaxControlToolKit控件(四)快速浏览AjaxControlToolKit控件(四)Code
<style type="text/css">
.validatorCalloutHighlight 
{
    background
-color: lemonchiffon; 
}
</style>
<table>
            
<tr>
                
<td>Name:</td>
                
<td><asp:TextBox runat="server" ID="NameTextBox"
                    BorderStyle
="solid" BorderWidth="1px" BorderColor="#a9a9a9" /></td>
            
</tr>
            
<tr>
                
<td>Phone Number:</td>
                
<td><asp:TextBox runat="server" ID="PhoneNumberTextBox"
                    BorderStyle
="solid" BorderWidth="1px" BorderColor="#a9a9a9" /></td>
            
</tr>
        
</table>
        
<br />
        
        
<asp:RequiredFieldValidator runat="server" ID="NReq"
            ControlToValidate
="NameTextBox"
            Display
="None"
            ErrorMessage
="<b>Required Field Missing</b><br />A name is required." />
        
<ajaxToolkit:ValidatorCalloutExtender runat="Server" ID="NReqE"
            TargetControlID
="NReq"
            HighlightCssClass
="validatorCalloutHighlight" />
            
        
<asp:RequiredFieldValidator runat="server" ID="PNReq"
            ControlToValidate
="PhoneNumberTextBox"
            Display
="None"
            ErrorMessage
="<b>Required Field Missing</b><br />A phone number is required.<div style='margin-top:5px;padding:5px;border:1px solid #e9e9e9;background-color:white;'><b>Other Options:</b><br /><a href='javascript:alert(&quot;No phone number available in profile.&quot;);'>Extract from Profile</a></div>" />
        
<ajaxToolkit:ValidatorCalloutExtender runat="Server" ID="PNReqE"
            TargetControlID
="PNReq"
            HighlightCssClass
="validatorCalloutHighlight"
            Width
="350px" />
            

快速浏览AjaxControlToolKit控件(四)

十五.AnimationExtender

主要属性:

1.TargetControlID:需要扩展打开效果的控件ID

2.OnLoad:页面加载的时候动画效果

3.OnClick:点击TargetControl的时候效果,遵循XML格式,事件下面以<Sequence>

为字节点,sequence下面可以加入:

EnableAction:是否能使用:针对TargetControlID

ScriptAction:执行脚本函数

StyleAction:执行样式改变

Parallel:打开的元素的相关样式

FadeIn:打开的元素的渐现效果

其他事件与onclick相同

4.其他事件:OnMouseOver,OnMouseOut,OnHoverOver,OnHoverOut

AnimationExtender是Ajaxtool中最绚丽的效果,官方demo中将其与Hover

MenuExtender配合使用

快速浏览AjaxControlToolKit控件(四)快速浏览AjaxControlToolKit控件(四)Code
 <div class="demoarea">
        
<div class="demoheading">Animation Demonstration</div>
        
<p>
            The animation support 
in the Toolkit is more than just a control.  It's a pluggable, extensible
            framework for easily adding animation effects to your web pages.
        
</p>
        
<p>
            The sample below demonstrates a composite animation consisting of four primary animation actions,
            done 
in parallel:
        
</p>
        
<ul>
            
<li>Move (to move the panel to its final location)</li>
            
<li>Resize (to change the size of the panel)</li>
            
<li>Fade (to fade the text in/out)</li>
            
<li>Color (the flyout changes from gray to white and the text pulses red)</li>
        
</ul>
        
<p>
            
<!-- Button used to launch the animation -->
            
<asp:Button ID="btnInfo" runat="server" OnClientClick="return false;" Text="Click Here"/>
        
</p>
        
<p>
            By composing basic animations (there are many to choose from
!) you can create very sophisticated
            effects, or use them independently from client code, server
-side code, or XML markup.
        
</p>

        
        
<!-- "Wire frame" div used to transition from the button to the info panel -->
        
<div id="flyout" style="display: none; overflow: hidden; z-index: 2; background-color: #FFFFFF; border: solid 1px #D0D0D0;"></div>
        
        
<!-- Info panel to be displayed as a flyout when the button is clicked -->
        
<div id="info" style="display: none; width: 250px; z-index: 2; opacity: 0; filter: progid:DXImageTransform.Microsoft.Alpha(opacity=0); font-size: 12px; border: solid 1px #CCCCCC; background-color: #FFFFFF; padding: 5px;">
            
<div id="btnCloseParent" style="float: right; opacity: 0; filter: progid:DXImageTransform.Microsoft.Alpha(opacity=0);">
                
<asp:LinkButton id="btnClose" runat="server" OnClientClick="return false;" Text="X" ToolTip="Close"
                    Style
="background-color: #666666; color: #FFFFFF; text-align: center; font-weight: bold; text-decoration: none; border: outset thin #FFFFFF; padding: 5px;" />
            
</div>
            
<div>
                
<p>
                    Once you 
get the general idea of the animation's markup, you'll want to play a bit.  All of
                    the animations are created from simple, reusable building blocks that you can compose together.
                    Before 
long you'll be creating dazzling visuals.  By grouping steps together and specifying
                    them to be run either in sequence or in parallel, you'll achieve almost anything you can
                    imagine, without writing a single line of code!
                
</p>
                
<br />
                
<p>
                    The XML defining the animations 
is very easy to learn and write, such as this example's
                    <asp:LinkButton id="lnkShow" OnClientClick="return false;" runat="server">show</asp:LinkButton> and
                    
<asp:LinkButton OnClientClick="return false;" id="lnkClose" runat="server">close</asp:LinkButton>
                    markup.
                
</p>
            
</div>
        
</div>
        
        
<script type="text/javascript" language="javascript">
            
// Move an element directly on top of another element (and optionally
            
// make it the same size)
            function Cover(bottom, top, ignoreSize) {
                var location 
= Sys.UI.DomElement.getLocation(bottom);
                top.style.position 
= 'absolute';
                top.style.top 
= location.y + 'px';
                top.style.left 
= location.x + 'px';
                
if (!ignoreSize) {
                    top.style.height 
= bottom.offsetHeight + 'px';
                    top.style.width 
= bottom.offsetWidth + 'px';
                }
            }
        
</script>
        
        
<ajaxToolkit:AnimationExtender id="OpenAnimation" runat="server" TargetControlID="btnInfo">
            
<Animations>
                
<OnClick>
                    
<Sequence>
                        
<%-- Disable the button so it can't be clicked again --%>
                        <EnableAction Enabled="false" />
                        
                        
<%-- Position the wire frame on top of the button and show it --%>
                        
<ScriptAction Script="Cover($get('btnInfo'), $get('flyout'));" />
                        
<StyleAction AnimationTarget="flyout" Attribute="display" Value="block"/>
                        
                        
<%-- Move the wire frame from the button's bounds to the info panel's bounds --%>
                        
<Parallel AnimationTarget="flyout" Duration=".3" Fps="25">
                            
<Move Horizontal="150" Vertical="-50" />
                            
<Resize Width="260" Height="280" />
                            
<Color PropertyKey="backgroundColor" StartValue="#AAAAAA" EndValue="#FFFFFF" />
                        
</Parallel>
                        
                        
<%-- Move the info panel on top of the wire frame, fade it in, and hide the frame --%>
                        
<ScriptAction Script="Cover($get('flyout'), $get('info'), true);" />
                        
<StyleAction AnimationTarget="info" Attribute="display" Value="block"/>
                        
<FadeIn AnimationTarget="info" Duration=".2"/>
                        
<StyleAction AnimationTarget="flyout" Attribute="display" Value="none"/>
                        
                        
<%-- Flash the text/border red and fade in the "close" button --%>
                        
<Parallel AnimationTarget="info" Duration=".5">
                            
<Color PropertyKey="color" StartValue="#666666" EndValue="#FF0000" />
                            
<Color PropertyKey="borderColor" StartValue="#666666" EndValue="#FF0000" />
                        
</Parallel>
                        
<Parallel AnimationTarget="info" Duration=".5">
                            
<Color PropertyKey="color" StartValue="#FF0000" EndValue="#666666" />
                            
<Color PropertyKey="borderColor" StartValue="#FF0000" EndValue="#666666" />
                            
<FadeIn AnimationTarget="btnCloseParent" MaximumOpacity=".9" />
                        
</Parallel>
                    
</Sequence>
                
</OnClick>
            
</Animations>
        
</ajaxToolkit:AnimationExtender>
        
<ajaxToolkit:AnimationExtender id="CloseAnimation" runat="server" TargetControlID="btnClose">
            
<Animations>
                
<OnClick>
                    
<Sequence AnimationTarget="info">
                        
<%--  Shrink the info panel out of view --%>
                        
<StyleAction Attribute="overflow" Value="hidden"/>
                        
<Parallel Duration=".3" Fps="15">
                            
<Scale ScaleFactor="0.05" Center="true" ScaleFont="true" FontUnit="px" />
                            
<FadeOut />
                        
</Parallel>
                        
                        
<%--  Reset the sample so it can be played again --%>
                        
<StyleAction Attribute="display" Value="none"/>
                        
<StyleAction Attribute="width" Value="250px"/>
                        
<StyleAction Attribute="height" Value=""/>
                        
<StyleAction Attribute="fontSize" Value="12px"/>
                        
<OpacityAction AnimationTarget="btnCloseParent" Opacity="0" />
                        
                        
<%--  Enable the button so it can be played again --%>
                        
<EnableAction AnimationTarget="btnInfo" Enabled="true" />
                    
</Sequence>
                
</OnClick>
                
<OnMouseOver>
                    
<Color Duration=".2" PropertyKey="color" StartValue="#FFFFFF" EndValue="#FF0000" />
                
</OnMouseOver>
                
<OnMouseOut>
                    
<Color Duration=".2" PropertyKey="color" StartValue="#FF0000" EndValue="#FFFFFF" />
                
</OnMouseOut>
             
</Animations>
        
</ajaxToolkit:AnimationExtender>
        
        
<asp:Panel ID="xmlShow" runat="server" style="display: none; z-index: 3; background-color:#DDD; border: thin solid navy;">
            
<pre style="margin: 5px">&lt;ajaxToolkit:AnimationExtender id="OpenAnimation" runat="server" TargetControlID="btnInfo"&gt;
&lt;Animations&gt;
    
&lt;OnClick&gt;
        
&lt;Sequence&gt;
           
<em>&lt;%-- Disable the button --%&gt;</em>
            
&lt;EnableAction Enabled="false" /&gt; 
           
<em>&lt;%-- Show the flyout --%&gt;</em>
            
&lt;Parallel AnimationTarget="flyout" Duration=".3" Fps="25"&gt;
                
&lt;Move Horizontal="150" Vertical="-50" /&gt;
                
&lt;Resize Height="260" Width="280" /&gt;
                
&lt;Color AnimationTarget="flyout" PropertyKey="backgroundColor"
                        StartValue
="#AAAAAA" EndValue="#FFFFFF" /&gt;
            
&lt;/Parallel&gt;
          
<em>&lt;%-- Fade in the text --%&gt; </em>
            
&lt;FadeIn AnimationTarget="info" Duration=".2"/&gt;
          
<em>&lt;%-- Cycle the text and border color to red and back --%&gt;</em>
            
&lt;Parallel AnimationTarget="info" Duration=".5"&gt;
                
&lt;Color PropertyKey="color"
                        StartValue
="#666666" EndValue="#FF0000" /&gt;
                
&lt;Color PropertyKey="borderColor"
                        StartValue
="#666666" EndValue="#FF0000" /&gt;
            
&lt;/Parallel&gt;
            
&lt;Parallel AnimationTarget="info" Duration=".5"&gt;
                
&lt;Color PropertyKey="color"
                        StartValue
="#FF0000" EndValue="#666666" /&gt;
                
&lt;Color PropertyKey="borderColor"
                        StartValue
="#FF0000" EndValue="#666666" /&gt;
                
&lt;FadeIn AnimationTarget="btnCloseParent" MaximumOpacity=".9" /&gt;
            
&lt;/Parallel&gt;
        
&lt;/Sequence&gt;
    
&lt;/OnClick&gt;
&lt;/Animations&gt;
&lt;/ajaxToolkit:AnimationExtender&gt;</pre>
        
</asp:Panel>
        
        
<asp:Panel ID="xmlClose" runat="server" style="display: none; z-index: 3; background-color: #DDD; border: thin solid navy;">
            
<pre style="margin: 5px">&lt;ajaxToolkit:AnimationExtender id="CloseAnimation" runat="server" TargetControlID="btnClose"&gt;
&lt;Animations&gt;
    
&lt;OnClick&gt;
        
&lt;Sequence AnimationTarget="info"&gt;
          
<em>&lt;%-- Scale the flyout down to 5% to make it disappear --%&gt;</em>
            
&lt;Parallel Duration=".3" Fps="15"&gt;
                
&lt;Scale ScaleFactor="0.05" Center="true"
                        ScaleFont
="true" FontUnit="px" /&gt;
                
&lt;FadeOut /&gt;
            
&lt;/Parallel&gt;
          
<em>&lt;%-- Reset the styles on the info box --%&gt;</em>
            
&lt;StyleAction Attribute="display" Value="none"/&gt;
            
&lt;StyleAction Attribute="width" Value="250px"/&gt;
            
&lt;StyleAction Attribute="height" Value=""/&gt;
            
&lt;StyleAction Attribute="fontSize" Value="12px"/&gt;
          
<em>&lt;%-- Re-enable the button --%&gt;</em>
            
&lt;EnableAction Enabled="true"
                    AnimationTarget
="btnInfo" /&gt;
        
&lt;/Sequence&gt;
    
&lt;/OnClick&gt;
&lt;/Animations&gt;
&lt;/ajaxToolkit:AnimationExtender&gt;
        
</pre>
        
</asp:Panel>
        
        
<ajaxToolkit:HoverMenuExtender ID="hm2" runat="server" TargetControlID="lnkShow" PopupControlID="xmlShow" PopupPosition="Bottom" />
        
<ajaxToolkit:HoverMenuExtender ID="hm1" runat="server" TargetControlID="lnkClose" PopupControlID="xmlClose" PopupPosition="Bottom" />
    
</div>  

 

快速浏览AjaxControlToolKit控件(四)

快速浏览AjaxControlToolKit控件(四)