Telerik blogs
As you already know, the upcoming RadControls for ASP.NET AJAX Q2 2008 release will add a new control to the suite - the RadRotator. If you are familiar with the RadRotator control from the classic ASP.NET controls suite, you will be glad to know that it is now included in the new Ajax suite as well.

 

One important change I would like to talk about is how the new rotator works with XML data. The classic rotator control had a property called ContentFile, which allowed the developer to specify a XML file to use as a datasource for the rotator frames. For example:


<rad:RadRotator id="RadRotator1" runat="server"  
ContentFile="news.xml" height="100px" width="300px"
  <FrameTemplate> 
    <div> 
      <%# DataBinder.Eval(Container.DataItem, "Title") %> 
    </div> 
  </FrameTemplate> 
</rad:RadRotator> 

 

The new RadRotator will not have a ContentFile property. Instead, the rotator should be bound to a XmlDataSource control, which in turn will load the XML file. Note that the XmlDataSource control can work with live XML streams (RSS) as well. Here is an example of how the new rotator will work with XML:

 

<telerik:RadRotator ID="RadRotator1" ScrollDirection="Up" ScrollDuration="2000" 
runat="server" DataSourceID="xmlDataSource1" Width="500" Height="200"
    <ItemTemplate> 
        <div class="module" style="width:500px"
            <strong><a href='<%# XPath("link") %>' target="_blank"
                <%# XPath("title") %> 
            </a></strong
            <br /> 
            <%# XPath("pubDate") %> 
        </div> 
    </ItemTemplate> 
</telerik:RadRotator> 
<asp:XmlDataSource ID="xmlDataSource1" XPath="rss/channel/item" runat="server" 
 DataFile="http://rss.cnn.com/rss/cnn_topstories.rss" /> 

 

The above example will bind the rotator to CNN's Top Stories RSS feed. Note that instead of DataBinder.Eval(), the XmlDataSource uses XPath() to get specific items from the data container. This means that if you are upgrading from the classic RadRotator with XML content file, you will need to update your template as well.

About the Author

Iana Tsolova

is Product Manager at Telerik’s DevTools division. She joined the company back in the beginning of 2008 as a Support Officer and has since occupied various positions at Telerik, including Senior Support Officer, Team Lead at one of the ASP.NET AJAX teams and Technical Support Director. Iana’s main interests are web development, reading articles related to geography, wild nature and latest renewable energy technologies.

Related Posts

Comments

Comments are disabled in preview mode.