This is a migrated thread and some comments may be shown as answers.

Need ItemClicked Example for Rotator

1 Answer 56 Views
Rotator
This is a migrated thread and some comments may be shown as answers.
Scott Griffin
Top achievements
Rank 1
Scott Griffin asked on 14 May 2009, 05:59 AM
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.

                                    <telerik:RadRotator ID="AdRotate" runat="server" AutoPostBack="True" RotatorType="AutomaticAdvance" FrameDuration="3000" DataSourceID="SQLRotate" 
                                        ScrollDirection="Up" Skin="Web20" Width="500px" Height="325px" OnItemClick="AdRotate_OnItemClick">  
                                        <Items> 
                                        <telerik:RadRotatorItem> 
                                            <ItemTemplate> 
                                            <table width="500" border="0" style="height:325px;" cellspacing="0" cellpadding="0">  
                                                <tr> 
                                                    <td colspan="2">  
                                                        <p> 
                                                            <b><%# Eval("Title") %></b></p> 
                                                        <p> 
                                                            <%# Eval("Body") %></p>  
                                                    </td> 
                                                </tr> 
                                                <tr> 
                                                    <td> 
                                                    <div style="width:500px">  
                                                        <div style="width:262px; margin-left:0px;">  
                                                            <strong>Contact: <%# Eval("ContactName") %></strong><br /> 
                                                            <strong><%# Eval("ContactNumber") %></strong><br /> 
                                                            <strong><a href="<%# Eval("ContactWebAddress") %>"><%# Eval("ContactWebAddress") %></a></strong></div>  
                                                    <div style="width:235px; margin-left:265px; position:relative; margin-top:-65px;">  
                                                    <img src="<%# Eval("LogoAddress") %>" height="80px" width="235px" alt="Sigma Financial Corporation" /> 
                                                        <asp:Image ID="logo" runat="server" Visible="false" Height="71px" Width="192px" /></div>  
                                                    </div> 
                                                    </td> 
                                                </tr> 
                                                <tr> 
                                                <td colspan="2"><hr></hr></td> 
                                                </tr> 
                                            </table> 
                                              
                                        </ItemTemplate> 
                                        </telerik:RadRotatorItem> 
                                        </Items> 
                                          
                                    </telerik:RadRotator> 
                                    <asp:SqlDataSource ID="SQLRotate" runat="server" ConnectionString="<%$ ConnectionStrings:BROKERConnectionString %>" 
                                        SelectCommand="SELECT [Title], [Body], [ContactName], [ContactNumber], [ContactWebAddress], [LogoAddress], [Link], [ind] FROM [AdList]">  
                                    </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

1 Answer, 1 is accepted

Sort by
0
Fiko
Telerik team
answered on 18 May 2009, 07:28 AM
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 
    } 
</script> 

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.


Greetings,
Fiko
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.
Tags
Rotator
Asked by
Scott Griffin
Top achievements
Rank 1
Answers by
Fiko
Telerik team
Share this question
or