Need ItemClicked Example for Rotator

2 posts, 0 answers
  1. Scott Griffin
    Scott Griffin avatar
    5 posts
    Member since:
    Feb 2009

    Posted 14 May 2009 Link to this post

    I have the ad rotator on the site but I am wanting to be able to track the clicks that happen.
    I see that there is a ItemClicked Event but I am not sure how to retrieve the info I need to make this work.

    1                                     <telerik:RadRotator ID="AdRotate" runat="server" AutoPostBack="True" RotatorType="AutomaticAdvance" FrameDuration="3000" DataSourceID="SQLRotate" 
    2                                         ScrollDirection="Up" Skin="Web20" Width="500px" Height="325px" OnItemClick="AdRotate_OnItemClick">  
    3                                         <Items> 
    4                                         <telerik:RadRotatorItem> 
    5                                             <ItemTemplate> 
    6                                             <table width="500" border="0" style="height:325px;" cellspacing="0" cellpadding="0">  
    7                                                 <tr> 
    8                                                     <td colspan="2">  
    9                                                         <p> 
    10                                                             <b><%# Eval("Title") %></b></p> 
    11                                                         <p> 
    12                                                             <%# Eval("Body") %></p>  
    13                                                     </td> 
    14                                                 </tr> 
    15                                                 <tr> 
    16                                                     <td> 
    17                                                     <div style="width:500px">  
    18                                                         <div style="width:262px; margin-left:0px;">  
    19                                                             <strong>Contact: <%# Eval("ContactName") %></strong><br /> 
    20                                                             <strong><%# Eval("ContactNumber") %></strong><br /> 
    21                                                             <strong><a href="<%# Eval("ContactWebAddress") %>"><%# Eval("ContactWebAddress") %></a></strong></div>  
    22                                                     <div style="width:235px; margin-left:265px; position:relative; margin-top:-65px;">  
    23                                                     <img src="<%# Eval("LogoAddress") %>" height="80px" width="235px" alt="Sigma Financial Corporation" /> 
    24                                                         <asp:Image ID="logo" runat="server" Visible="false" Height="71px" Width="192px" /></div>  
    25                                                     </div> 
    26                                                     </td> 
    27                                                 </tr> 
    28                                                 <tr> 
    29                                                 <td colspan="2"><hr></hr></td> 
    30                                                 </tr> 
    31                                             </table> 
    33                                         </ItemTemplate> 
    34                                         </telerik:RadRotatorItem> 
    35                                         </Items> 
    37                                     </telerik:RadRotator> 
    38                                     <asp:SqlDataSource ID="SQLRotate" runat="server" ConnectionString="<%$ ConnectionStrings:BROKERConnectionString %>" 
    39                                         SelectCommand="SELECT [Title], [Body], [ContactName], [ContactNumber], [ContactWebAddress], [LogoAddress], [Link], [ind] FROM [AdList]">  
    40                                     </asp:SqlDataSource> 

    Can someone help out with suggestions  for the codebehind?

    If I can get the "Link"  Value that would be great it would be simple from there but same with getting the "ind" value would be just as good
  2. Fiko
    Fiko avatar
    1406 posts

    Posted 18 May 2009 Link to this post

    Hi Scott Griffin,

    You can get a reference to the clicked item and then retrieve the HTML content as shown bellow :

    <script type="text/javascript"
        function onClientItemClicked(oRotator, args) 
            var clickedElement = args.get_item().get_element(); // Get the HTML element 
            alert(clickedElement.innerHTML); // print the content 

    Then you need to find the desired element in that element according to the template that you  declared. I have attached a simple demo to the thread that demonstrates that approach.
    I hope this helps.

    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
Back to Top