Programmatically start the animation using fake target

Last post 06-28-2008 7:37 AM by Dmitry Perets. 3 replies.

Sort Posts:

  • Programmatically start the animation using fake target

    06-11-2008, 3:45 PM

    Hello,

     I am trying to accomplish the following: I have a gridview which has a button column. And also I have a usual asp:button. This usual button is actually a TargetControl for the AnimationExtender from the AjaxControlToolkit. When the user clicks the button inside the gridview, I want the usual button to be clicked also, and I expect the animation to run. So here is what I have:

     On the aspx page:

    1    <%@ Page Language="C#" AutoEventWireup="true" CodeFile="BuyerHome.aspx.cs" Inherits="BuyerHome" %>
    2   
    3    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    4   
    5    <html runat="server" xmlns="http://www.w3.org/1999/xhtml" dir="<%$ Resources: GlobalResources, PageDirection %>">
    6    <head runat="server">
    7        <title></title>
    8        <link rel="stylesheet" type="text/css" href="~/Styles/Global.css" />   
    9        <link rel="stylesheet" type="text/css" href="~/Styles/BuyerHome.css" />   
    10   </head>
    11   <body>
    12  
    13       <form id="form1" runat="server">
    14       <div>
    15           <asp:ScriptManager ID="ScriptManager1" runat="server" />
    16       </div>
    17  
    18       <br />
    19  
    20       <asp:UpdatePanel ID="UpdatePanel1" runat="server">
    21           <ContentTemplate>
    22  
    23               <div>
    24                   <asp:GridView ID="grdContracts" CssClass="contractsGrid" runat="server"
    25                   AutoGenerateColumns="false" OnRowCommand="grdContracts_RowCommand" >
    26                       <Columns>
    27                           <asp:BoundField DataField="Description" HeaderText="Description" />
    28                           <asp:BoundField DataField="OpenDate" HeaderText="OpenDate" />
    29                           <asp:BoundField DataField="ParticipateDate" HeaderText="ParticipateDate" />
    30                           <asp:BoundField DataField="CloseDate" HeaderText="CloseDate" />
    31                           <asp:ButtonField ButtonType="Button" Text="Documents" CommandName="ShowDocs" />
    32                       </Columns>
    33                   </asp:GridView>
    34               </div>
    35  
    36               <asp:Button ID="btnFakeTarget" runat="server" OnClientClick="alert('Clicked!'); return false;" Text="Animate" />
    37               <ajaxToolkit:AnimationExtender ID="AnimationExtender1" runat="server"
    38                                              TargetControlID="btnFakeTarget">
    39                   <Animations>
    40                       <OnClick>
    41                           <Color PropertyKey="color" StartValue="#FF0000" EndValue="#666666"></Color>
    42                       </OnClick>
    43                   </Animations>
    44               </ajaxToolkit:AnimationExtender>
    45              
    46           </ContentTemplate>
    47       </asp:UpdatePanel>
    48       </form>
    49   </body>
    50   </html>
    51  

     And here is the code-behind listing:

    1        protected void grdContracts_RowCommand(object sender, GridViewCommandEventArgs e)
    2        {
    3            if (e.CommandName == "ShowDocs")
    4            {
    5                ScriptManager.RegisterStartupScript
    6                    (this, this.GetType(), "PlayAnimationScript", 
    7                    "alert(Running script!'); $get('" + btnFakeTarget.UniqueID + "').click();", true);
    8            }
    9        }
    10   
    

     Now, the problem is that this doesn't work =) I do see both "Running script" and "Clicked!" alerts, which means that the script actually runs correctly. But the animation just doesn't run! If I simply click the "Animate" button, it does run.

    Any ideas?

  • Re: Programmatically start the animation using fake target

    06-12-2008, 2:07 AM
    Chetan Sarode
    Software Engineer,
    Approva Systems Pvt Ltd,
    Pune, India.
  • Re: Programmatically start the animation using fake target

    06-13-2008, 11:11 AM

    Sorry, I can't see how this helps me. I can't make the gridview button be a trigger, because the whole problem is that I can't refer to it by ID in design time...

  • Re: Programmatically start the animation using fake target

    06-28-2008, 7:37 AM
    Answer

    Well, I've found the way to programmatically start the animation. We can start it using client-side javascript. I've put an example here:

    http://forums.asp.net/t/1281899.aspx

Page 1 of 1 (4 items)