Basic Problem

6 posts, 0 answers
  1. Mark
    Mark avatar
    20 posts
    Member since:
    Nov 2006

    Posted 26 Nov 2009 Link to this post

    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?
  2. Georgi Tunev
    Admin
    Georgi Tunev avatar
    7207 posts

    Posted 27 Nov 2009 Link to this post

    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.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Mark
    Mark avatar
    20 posts
    Member since:
    Nov 2006

    Posted 27 Nov 2009 Link to this post

    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.
  5. Mark
    Mark avatar
    20 posts
    Member since:
    Nov 2006

    Posted 27 Nov 2009 Link to this post

    Ah, no sorry - got it!
    I changed the width to 100 instead of 200, and it's working great now.

    Thanks for the help!
  6. Mark
    Mark avatar
    20 posts
    Member since:
    Nov 2006

    Posted 27 Nov 2009 Link to this post

    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?
  7. Lini
    Admin
    Lini avatar
    2144 posts

    Posted 27 Nov 2009 Link to this post

    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.
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017