Hi folks
I have a situation where I want to animate a panel inside a Gridview.
Using another post on here as an example I have managed to write some code that will reference the correct panel (in the same row as the button that starts the animation) and will animate it.
The problem comes when I sort or page the Gridview, once I have done this, the animation stops working.
Below is the code which ensures the correct panel is animated.
1 Protected Sub GridView1_RowDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles GridView1.RowDataBound
2
3 Dim row As GridViewRow = e.Row
4 Dim panel As HtmlGenericControl = CType(row.FindControl("panel1"), HtmlGenericControl)
5
6 If Not panel Is Nothing Then
7 Dim animation As AjaxControlToolkit.AnimationExtender = CType(row.FindControl("TryMe"), AjaxControlToolkit.AnimationExtender)
8
9 animation.OnClick.Properties("AnimationTarget") = panel.ClientID
10
11 Dim animClose As AjaxControlToolkit.AnimationExtender = CType(row.FindControl("ClosePopup"), AjaxControlToolkit.AnimationExtender)
12
13 animClose.OnClick.Properties("AnimationTarget") = panel.ClientID
14 animClose.OnClick.Children(0).Properties("AnimationTarget") = row.FindControl("btnAnimate").ClientID
15
16 End If
17
18 End Sub
And this is what the actual template in the GridView looks like...
1 <ItemTemplate>
2 <div style="text-align: center">
3
4 <asp:LinkButton ID="btnAnimate" runat="server" Text="Tech Comment" OnClientClick="return false;" Visible='<%# ShowTechComments(Eval("TechnicalComment")) %>' />
5
6 <div id="panel1" class="technicalComment" style="display:none;z-index:2;overflow:hidden;position:absolute;" runat="server">
7
8 <div style="float:right;" id="btnCloseParent">
9 <asp:LinkButton id="btnClose" runat="server" OnClientClick="return false;" Text="" Style="text-align: right;border:outset thin white; padding: 5px; text-decoration: none; background-color:#666666;color:White;text-align:center;font-weight:bold;" ToolTip="Close">X</asp:LinkButton></div>
10
11 <asp:Label ID="lblTechnicalNotes" runat="server" text='<%# Eval("TechnicalComment") %>'></asp:Label>
12
13 </div>
14
15 <ajaxToolkit:AnimationExtender ID="TryMe" TargetControlID="btnAnimate" runat="server">
16 <Animations>
17 <OnClick>
18 <Sequence>
19 <OpacityAction Opacity="0" />
20 <Parallel Duration="0.1">
21 <StyleAction Attribute="height" value="auto" />
22 <StyleAction Attribute="display" Value="block" />
23 </Parallel>
24 <Parallel Duration=".2">
25 <FadeIn/>
26 </Parallel>
27 </Sequence>
28 </OnClick>
29 </Animations>
30 </ajaxToolkit:AnimationExtender>
31
32 <ajaxToolkit:AnimationExtender ID="ClosePopup" TargetControlID="btnClose" runat="server">
33 <Animations>
34 <OnClick>
35 <Sequence>
36 <EnableAction Enabled="true" />
37 <Parallel Duration=".3" Fps="15">
38 <FadeOut />
39 <StyleAction Attribute="display" Value="none" />
40 </Parallel>
41 </Sequence>
42
43 </OnClick>
44 </Animations>
45 </ajaxToolkit:AnimationExtender>
46 </div>
47
48 </ItemTemplate>