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

Linking Text in Rotator Using XMLDataSource

1 Answer 71 Views
Rotator
This is a migrated thread and some comments may be shown as answers.
Tommy
Top achievements
Rank 1
Tommy asked on 13 Jul 2009, 02:35 PM
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

1 Answer, 1 is accepted

Sort by
0
Mehdi Mirza
Top achievements
Rank 1
answered on 13 Jul 2009, 08:27 PM
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
Tags
Rotator
Asked by
Tommy
Top achievements
Rank 1
Answers by
Mehdi Mirza
Top achievements
Rank 1
Share this question
or