Linking Text in Rotator Using XMLDataSource

2 posts, 0 answers
  1. Tommy
    Tommy avatar
    23 posts
    Member since:
    Jun 2009

    Posted 13 Jul 2009 Link to this post

    Ok, I need help or a good example of how to do this.

    Here's what I have been attempting, using the rss demo example, I can get an rss feed to display but I can't do it with simple xml ...

    Here's the xml i'm using:
    <?xml version="1.0" encoding="utf-8" ?> 
    <RoatatorItems> 
      <Item link="http://www.link1.com" title="This is a test 1" /> 
      <Item link="http://www.link2.com" title="This is a test 2" /> 
      <Item link="http://www.link3.com" title="This is a test 3" /> 
      <Item link="http://www.link4.com" title="This is a test 4" /> 
      <Item link="http://www.link5.com" title="This is a test 5" /> 
    </RoatatorItems> 


    Here's the aspx page code ...
    <asp:XmlDataSource ID="XmlDataSource1" runat="server"   
        DataFile="~/NewsRotator.xml" XPath="/RotatorItems/Items"></asp:XmlDataSource> 
    <telerik:RadRotator ID="RadRotator1" runat="server"   
        DataSourceID="XmlDataSource1" Height="50px" Width="901px">  
        <ItemTemplate> 
            <div class="newsFeed">  
                <strong><a href='<%# XPath("link") %>'>  
                  <%# System.Web.HttpUtility.HtmlEncode(XPath("title").ToString()) %> 
                </a></strong>  
            </div> 
        </ItemTemplate> 
    </telerik:RadRotator> 

    I also tried:


        <ItemTemplate> 
            <div class="newsFeed">  
                <strong><a href='<%# XPath("link") %>'>  
                    <%#XPath("title")%> 
                </a></strong>  
                <br /> 
            </div> 
        </ItemTemplate> 


    What's wrong with it as I get nothing ... I have nothing in the VB codebehind ....
    Is the XML formatted properly for this or is there a better example you can provide of how this would work?
    Thanks in advance!

    TT
  2. Mehdi Mirza
    Mehdi Mirza avatar
    11 posts
    Member since:
    Apr 2009

    Posted 13 Jul 2009 Link to this post

    hey Tommy,

    here is the aspx code:
    <asp:XmlDataSource ID="XmlDataSource1" runat="server" DataFile="NewsRotator.xml" 
               ></asp:XmlDataSource> 
            <telerik:RadRotator ID="RadRotator1" RotatorType="ButtonsOver" ScrollDirection="Up" 
                ScrollDuration="2000" runat="server" FrameDuration="1" 
                DataSourceID="XmlDataSource1" Height="50px" Width="901px">  
                <ItemTemplate> 
                            <div > 
                        <strong><a href='<%# XPath("Link") %>'>  
                            <%# System.Web.HttpUtility.HtmlEncode(XPath("title").ToString()) %> 
                        </a></strong>  
                        <br /> 
                        <%# XPath("pubDate") %> 
                    </div> 
     
                         </ItemTemplate> 
     
            </telerik:RadRotator> 

    here is the xml file i used for this example

    <?xml version="1.0" encoding="utf-8" ?>    
    <RoatatorItems> 
        <item> 
            <title>This is a test 1</title> 
            <Link>http://www.link1.com</Link> 
        </item> 
        <item> 
            <title>This is a test 2</title> 
            <Link>http://www.link2.com</Link> 
        </item>    
        <item> 
            <title>This is a test 3</title> 
            <Link>http://www.link3.com</Link> 
        </item>      
        <item> 
            <title>This is a test 4</title> 
            <Link>http://www.link4.com</Link> 
        </item>    
        <item> 
            <title>This is a test 5</title> 
            <Link>http://www.link5.com</Link> 
        </item>    
        
    </RoatatorItems>    
     

    I have tested it and it worked for me.

    thanks

    Mehdi
  3. UI for ASP.NET Ajax is Ready for VS 2017
Back to Top