Building a User Control that displays RSS feeds

Introduction
Displaying data in ASP.NET verison 1.x required writing code to programmatically retrieve the data and then more code to bind the data to a data Web control, such as the DataGrid. ASP.NET 2.0 simplifies the process of working with data through its data source controls, which allow data to be retrieved and even modified through declarative means. In short, ASP.NET 2.0's data source controls permit developers to work with and display data without having to write a line of code. For a more thorough look at working with data in ASP.NET 2.0, be sure to check out my Accessing and Updating Data in ASP.NET 2.0 article series.

Different data source controls are designed to work with different types of data. The XmlDataSource control, as its name implies, is designed for working with XML data. By setting a few properties, it is possible to retrieve XML data from a remote URL or local file, transform it using XSLT, and filter it using an XPath expression, all without writing a line of code. This data can then be displayed by binding it to a data Web control and XPath databinding statements can be used to bind specific chunks of the resulting XML to other Web controls.

In this article we will see just how easy it is to display XML data in an ASP.NET 2.0 page. In particular, we will build a User Control that will display the contents of an RSS feed. Once created, this User Control can be dragged onto the Design surface of any ASP.NET page in your project and configured to display the contents of a particular RSS feed by simply setting the control's Url property to the URL of the RSS feed.

Read on to learn more!

No Comments