Click here to Skip to main content
13,254,366 members (66,757 online)
Click here to Skip to main content
Add your own
alternative version


21 bookmarked
Posted 10 Nov 2006

User control to display RSS channels

, 10 Nov 2006
Rate this:
Please Sign up or sign in to vote.
Add news content to any ASPX page, and configure the control easily.

Sample Image - rssreader.gif


This user control displays one or more RSS channels in an HTML table. It also includes a method (not used in the example) to download the content of the channel for later use. The difference between this control and other controls or services like rss-info is that the appearance of the control can be configured with the same CSS styles used in the rest of your application.

Using the Code

Include the user control in your app and add it to the desired page.

The control has these properties:

MainTableCssName of the CSS style to apply to the table which contains all the feeds.
ChannelCssName of the CSS style to apply to the name of the RSS channel.
LinkCssName of the CSS style to apply to the link associated with the current news.
LinkCellCssName of the CSS style to apply to the cell which contains the news title.
ContentCssName of the CSS style to apply to the cell which contains the text of the news.
showContentIf this flag is true, the content of the news will be displayed; otherwise, only the title and link will be displayed. The default value is false.
widthWidth of the table which contains all the feeds (pixels); if it is not specified, the default value is 100.
urlsString array which contains all the RSS channel URLs to show.
newsNumberNumber of news to show per channel; if it is not specified, the control will display all the news.
showContentInHtmlIf the flag is true, the content of the news will be displayed as HTML; otherwise, it will be displayed in text format. The default format is text.

And a method:

DownloadFeedThis function returns all the data returned to the browser by a URL. This can be an HTML page or whatever; you can use this string to save the content to a file.

Example use:

//This code is in the example aspx.cs page

string [] channels= new string[3];
channels[0] = "";
channels[1] = "";
channels[2] = "" + 
              "=org.mozilla:es-ES:official&ie=UTF-8&oe=UTF-8&hl=" + 
              "es&client=firefox-a&rls=org.mozilla:es-ES:" + 

Rssfeed1.urls = channels;
Rssfeed1.width = 150;
Rssfeed1.showContent = true;
Rssfeed1.showContentInHtml = true;
Rssfeed1.ChannelCss = "GrayBackgroundActive";
Rssfeed1.ContentCss = "NormalLetter";
Rssfeed1.LinkCss = "projectletter";
Rssfeed1.newsNumber = 3;

Points of Interest

The control uses a dataset to populate the table, and that dataset is filled directly from the RSS channel with the method ReadXml(), but some channels throw an error because the item "link" is repeated in the same node; when this happens, you will see an error.

In this case, you could use the method DownloadFeed of the control to download the content of the channel and parse it as you wish. But the control works fine with most RSS channels; in the sample code, the Google News channel and two othres are used.


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


About the Author

Web Developer
Mexico Mexico
I am Pedro Ramirez from mexico, work for, the company is located in Mexico, we do outsourcing and nearshore development, we are focused on SaaS nearshore development, I started with VB.Net, but now I am ambidextrous using VB.Net or C#.

You may also be interested in...


Comments and Discussions

GeneralMy vote of 1 Pin
jajohnston18-Jun-09 12:51
memberjajohnston18-Jun-09 12:51 
nice idea. doesn't work.

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Terms of Use | Mobile
Web01 | 2.8.171114.1 | Last Updated 10 Nov 2006
Article Copyright 2006 by Pramirez
Everything else Copyright © CodeProject, 1999-2017
Layout: fixed | fluid