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

RadRotator Item Data

1 Answer 226 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Mohit
Top achievements
Rank 1
Mohit asked on 07 Jan 2011, 03:50 PM
Hi all,

I have a problem accessing the Item data from RadRotator.
I have created a custom control using RadRotator. I have an image and a Hyper link in my rad rotator.

<sf:RadRotator ID="ImageRotatorId" runat="server" RotatorType="AutomaticAdvance" WrapFrames= "true" Width="550px" Height="260px">
    <ItemTemplate>
            <div>
                <asp:Image runat="server" ID="newsImage" style = "width:550px; height:260px; "></asp:Image>
            </div>
            <div>
                <asp:HyperLink onclick ="toggleLocation()" runat= "server" id="caption" width ="550px">
                </asp:HyperLink>
            </div>
    </ItemTemplate>
</sf:RadRotator>
<panel id = "location_map" visible = "false"> </panel>

now I want to get the data associated with my image ($find('<%= ImageRotatorId.ClientID %>')).get_currentItem() gives me the current element but how to get the data associated with this element in my java script.


Thanks,
Mohit

1 Answer, 1 is accepted

Sort by
0
Rumen
Telerik team
answered on 12 Jan 2011, 01:51 PM
Hi Mohit,

Here is an example on how to obtain a reference to the IMG tag inside the currently selected item:

<telerik:RadRotator runat="server" ID="ImageRotatorId" RotatorType="AutomaticAdvance"
    WrapFrames="true" Width="550px" Height="260px">
    <Items>
        <telerik:RadRotatorItem>
            <ItemTemplate>
                <img src="Images/Pets.jpg" width="400px" /></ItemTemplate>
        </telerik:RadRotatorItem>
        <telerik:RadRotatorItem>
            <ItemTemplate>
                <img src="Images/Pets.jpg" width="400px" /></ItemTemplate>
        </telerik:RadRotatorItem>
    </Items>
</telerik:RadRotator>
<input type="button" onclick="GetCurrentItemData();return false;" value="Get Current Item Data" />
<script type="text/javascript">
    function GetCurrentItemData() {
        var currentItemHtml = $find('<%= ImageRotatorId.ClientID %>').get_currentItem().get_element();
        alert(currentItemHtml.innerHTML);
        var image = currentItemHtml.getElementsByTagName("IMG");
        alert(image[0].width);
    }
</script>

$find('<%= ImageRotatorId.ClientID %>').get_currentItem().get_element(); returns the HTML of the currently selected item.

Best regards,
Rumen
the Telerik team
Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.
Tags
General Discussions
Asked by
Mohit
Top achievements
Rank 1
Answers by
Rumen
Telerik team
Share this question
or