posts - 22, comments - 17, trackbacks - 0, articles - 1
  博客园 :: 首页 :: 新随笔 :: 联系 :: 订阅 订阅 :: 管理

 微软的示例中是点击一个按钮实现效果,而且AnimationExtender要绑定这个按钮
   在gridview的行中的按钮可是跟行一样多,而且还得确保每次AnimationExtender显示的内容不一样
  以下是实现方法。
1. 上来当然还是把控件添到网页
<cc1:AnimationExtender ID="AnimationExtender1"  runat="server" TargetControlID="Button2">
         <Animations>
                <OnClick>
                    <Sequence>
                       
                        <EnableAction Enabled="false" />
                       
                       
                        <ScriptAction Script="Cover($get('ctl00_SampleContent_btnInfo'), $get('flyout'));" />
                       
                       
                       
                        <ScriptAction Script="Cover($get('flyout'), $get('info'), true);" />
                        <StyleAction AnimationTarget="info" Attribute="display" Value="block"/>
                        <FadeIn AnimationTarget="info" Duration=".2"/>
                       
                       
                       
                        <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>
        </cc1:AnimationExtender>
        <cc1: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"  ScaleFont="true" FontUnit="px" />
                            <FadeOut />
                        </Parallel>
                       
                        <%--  Reset the sample so it can be played again --%>
                        <StyleAction Attribute="display" Value="none"/>
                        <StyleAction Attribute="width" Value="95%"/>
                        <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="Button2" 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>
        </cc1:AnimationExtender>

和AnimationExtender1关联的按钮TargetControlID="Button2" 我用样式把他隐藏
<asp:Button ID="Button2" OnClientClick="return false;" runat="server" Text="Button" style="visibility:hidden;" />

接下来是添加gridview
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
            <ContentTemplate>
     <asp:HiddenField ID="HiddenField1" runat="server" />
        <asp:GridView ID="GridView1" runat="server" AllowPaging="True" AutoGenerateColumns="False"
             Width="655px" SkinID="GridView" OnRowDataBound="GridView1_RowDataBound" PageSize="15" OnPageIndexChanging="GridView1_PageIndexChanging" OnDataBound="GridView1_DataBound">
            <Columns>
                <asp:TemplateField HeaderText="日期">
                    <EditItemTemplate>
                    </EditItemTemplate>
                   
                    <ItemTemplate><asp:LinkButton ID="LinkButton 3" Text='<%#Eval("l_date","{0:d}")%>' CommandArgument='<%#Eval("id") %>' runat="server" OnClick="LinkButton 3_Click" OnClientClick="javascript:document.getElementById('Button2').click();" CausesValidation="False"></asp:LinkButton>
                    </ItemTemplate>
                </asp:TemplateField>
                <asp:TemplateField HeaderText="添加时间">
                    <EditItemTemplate>
                    </EditItemTemplate>
                     <ItemStyle Width="150px" HorizontalAlign="Center" />
                    <ItemTemplate>
                 <asp:Label ID="Label1" runat="server" Text='<%# Bind("l_adddate") %>'></asp:Label>
                 </ItemTemplate>
                </asp:TemplateField>
                <asp:TemplateField HeaderText="批阅">
                    <EditItemTemplate>
                        <asp:TextBox ID="TextBox3" runat="server" Text='<%# Bind("l_sid") %>'></asp:TextBox>
                    </EditItemTemplate>
                    <ItemTemplate>
                        <asp:Label ID="Label2" runat="server" Text='<%# Bind("l_reply") %>'></asp:Label>
                    </ItemTemplate>
                    <ItemStyle Width="30px" ForeColor="Red" HorizontalAlign="Center" />
                </asp:TemplateField>
                <asp:TemplateField HeaderText="修改" ShowHeader="False">
                    <ItemStyle Width="30px" />
                    <ItemTemplate>
                       <asp:HyperLink ID="HyperLink2" runat="server" NavigateUrl='<%#string.Format("log_add.aspx?id={0}",Eval("id")) %>'>修改</asp:HyperLink>
                </ItemTemplate>
                </asp:TemplateField>
                <asp:TemplateField HeaderText="删除" ShowHeader="False">
                    <ItemStyle Width="30px" />
                    <ItemTemplate>
                        <asp:LinkButton ID="LinkButton2" runat="server" CausesValidation="false" CommandName="del"  CommandArgument='<%# Eval("id") %>'    Text="删除" OnClientClick='return confirm("确定删除?");' OnClick="LinkButton2_Click"></asp:LinkButton>
                    </ItemTemplate>
                </asp:TemplateField>
            </Columns>
        </asp:GridView>
            </ContentTemplate>
        </asp:UpdatePanel>

主要是蓝色标记的那部分,当然后台事件自己写
还少点东西就是那个div 在把他们拷近来就可以了
<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:95%; z-index: 2; opacity: 0; filter: progid:DXImageTransform.Microsoft.Alpha(opacity=0); font-size: 12px; border: solid 1px #CCCCCC; background-color: #F3F3F3; padding: 5px; left: 10px; position: absolute; top: 10px;">
            <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>
               <asp:UpdatePanel ID="UpdatePanel2" runat="server">
            <ContentTemplate> <table width="98%" border="0" align="center" cellpadding="3" cellspacing="1" class="table">
 <tr class="hback">
  <td  class="xingmu" >
            日志:<asp:Label ID="l_date" runat="server" Text="Label"></asp:Label>&nbsp; --&nbsp;
            <asp:Label ID="u_name" runat="server" Text="Label"></asp:Label></td>
           </tr>
</table>
</ProgressTemplate>
        </asp:UpdateProgress>

 </div>
        </div>

至此结束!

Feedback

#1楼    回复  引用    

2007-11-09 13:43 by 朱 [未注册用户]
很好的东西!谢谢楼主提供!
不过有一个问题就是第一次点击按钮出现的窗口是正常的,接下来弹出的窗口的宽度都不同了,是怎么回事呢?

#2楼    回复  引用    

2007-11-09 13:49 by 朱 [未注册用户]
解决了<StyleAction Attribute="width" Value="280"/>

#3楼    回复  引用    

2007-11-09 14:24 by 朱 [未注册用户]
还有问题哦,就是通过获取点击按钮的CommandArgument值来改变info的div标签,后台代码中调试的值是获取到了,但是没有回发服务器info里面的值还是改变不了,怎么办啊?谢谢大侠,急!!!!!

#4楼 [楼主]   回复  引用  查看    

2007-11-09 19:50 by yuanws      
不是有这个事件吗OnClick="LinkButton 3_Click"
在这里更新info里面的值

#5楼    回复  引用  查看    

2007-12-07 19:45 by randomx      
出发了这个事件不是造成页面刷新了么?OnClick="LinkButton 3_Click" 为什么我没有调试通过呢?

#6楼    回复  引用    

2008-01-16 21:17 by Newer [未注册用户]
LZ能否发份代码给我,我研究半天,还是有点问题~~~

#7楼    回复  引用    

2008-06-06 00:11 by by suzongwei [未注册用户]
楼2 <StyleAction Attribute="width" Value="280"/>
这个要加在哪一段呢 ?我 加了 这么实现不了呢?

#8楼    回复  引用    

2008-07-07 01:21 by 波波LVOE [未注册用户]
楼主。。。。 我试的时候为什么说document.getElementById()对象为空或者不是对象? 取不到BUTTON2啊。。。。
能否发一份代码给我研究一下。谢谢。

标题  
姓名  
主页
Email (只有博主才能看到) 
验证码 *  看不清,换一张 [登录][注册]
内容(请不要发表任何与政治相关的内容)  
  登录  使用高级评论  新用户注册  返回页首  恢复上次提交      
 
另存  打印