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

Basic Problem

5 Answers 76 Views
Rotator
This is a migrated thread and some comments may be shown as answers.
Mark
Top achievements
Rank 1
Mark asked on 26 Nov 2009, 02:08 PM
Hi,

I'm new to this control and seem to be having some trouble getting it to work correctly. I've got an XML file as the data source, however the control only ever shows the first item in the list.

My code is as follows:

        <telerik:RadRotator ID="RadRotator1" runat="server" DataSourceID="xmlData" RotatorType="AutomaticAdvance" ScrollDuration="2000" ScrollDirection="Up" FrameDuration="1" Height="200" ItemHeight="100" Width="200" ItemWidth="100">  
            <ItemTemplate> 
                <%#System.Web.HttpUtility.HtmlEncode(XPath("Message").ToString())%> 
            </ItemTemplate> 
        </telerik:RadRotator> 
        <asp:XmlDataSource ID="xmlData" DataFile="Messages.xml" XPath="Messages" runat="server"></asp:XmlDataSource> 
 

XML Source:

<?xml version="1.0" encoding="utf-8" ?> 
<Messages> 
  <Message>Frasers Message</Message> 
  <Message>Marks message</Message> 
  <Message>Jimmys message</Message> 
</Messages> 
 

It's probably something obvious - can anyone help me out please?

5 Answers, 1 is accepted

Sort by
0
Georgi Tunev
Telerik team
answered on 27 Nov 2009, 08:10 AM
Hi Mark,

The problem here is in the way XPath works. More information on the subject is available in this tutorial:
http://www.w3schools.com/XPath/default.asp

For your code to work, you should modify it like this:
<?xml version="1.0" encoding="utf-8" ?>
<Messages>
  <Message>
    <text>Frasers Message</text>
  </Message>
  <Message>
    <text>Marks message</text>
  </Message>
  <Message>
    <text>Jimmys message</text>
  </Message>
</Messages>

<telerik:RadRotator
    ID="RadRotator1"
    runat="server"
    DataSourceID="xmlData"
    RotatorType="AutomaticAdvance"
    ScrollDuration="2000"
    ScrollDirection="Up"
    FrameDuration="1"
    Height="200"
    ItemHeight="100"
    Width="200"
    ItemWidth="100">
    <ItemTemplate>
        <%#System.Web.HttpUtility.HtmlEncode(XPath("text").ToString())%>
    </ItemTemplate>
</telerik:RadRotator>
<asp:XmlDataSource
    ID="xmlData"
    DataFile="banner1.xml"
    runat="server">
</asp:XmlDataSource>

I hope this helps.

Kind regards,
Georgi Tunev
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
Mark
Top achievements
Rank 1
answered on 27 Nov 2009, 08:23 AM
Hi,

Thanks for the reply - but sorry, that didn't work. Well, it didn't work the way I was hoping anyway!

I'm trying to get the XML content to rotate vertically, but that just placed all 3 items on the screen with the top 2 sitting beside each other and the third underneath.
0
Mark
Top achievements
Rank 1
answered on 27 Nov 2009, 08:27 AM
Ah, no sorry - got it!
I changed the width to 100 instead of 200, and it's working great now.

Thanks for the help!
0
Mark
Top achievements
Rank 1
answered on 27 Nov 2009, 08:38 AM
I suspect the answer to this is no, but I thought I'd ask anyway!

I'm building a system that is going to constantly display messages that are in the XML file. However, the XML file will be constantly updated with new messages.
Is there any way to get the control to take the new messages into account withouth having to reload?
0
Lini
Telerik team
answered on 27 Nov 2009, 04:20 PM
Hello,

The rotator databinding happens on the server, which means that you will need to refresh it in order use the updated XML file. You can put the control in an ajax panel and use a timer control to perform the update - for example http://demos.telerik.com/aspnet-ajax/ajax/examples/common/ajaxifytimer/defaultcs.aspx

Best wishes,
Lini
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Tags
Rotator
Asked by
Mark
Top achievements
Rank 1
Answers by
Georgi Tunev
Telerik team
Mark
Top achievements
Rank 1
Lini
Telerik team
Share this question
or