About a year ago or so I wanted to add the ability to syndicate my news page. Therefore I wrote this small library which did the trick for me.
The Provider:
If you want to provide an RSS feed, you should use the Wilco.Web.Rss.RssProvider servercontrol. After dropping it on an empty page, you only need to build a DataTable data source and set a few properties. This would result in something like:
1
2
3
4
5
6
7
8
9
|
..
DataTable source = this.GetDataSource();
this.provider.Feed = new RssFeed();
this.provider.Feed.Data = source;
this.provider.Feed.Elements.Add("title", "My RSS Feed!");
this.provider.Feed.Elements.Add("link", "http://www.domain.com/");
this.provider.Feed.Columns.Add(new Column("title", "NewsItemTitle"));
this.provider.Feed.Columns.Add(new Column("link", "NewsID", "http://www.domain.com/entry.aspx?id={0}"));
..
|
The Reader:
The RSS reader's usage should be similar to standard ASP.NET controls such as a Repeater and DataList. All you need to do is set the Source and call DataBind(). A default template will be used if no template is defined. If you do want to define a custom template, you can do so just like you would with a Repeater:
1
2
3
4
5
6
7
8
9
10
11
|
<script language="C#" runat="server">
void Page_Load(object sender, EventArgs e)
{
reader.Source = "http://www.domain.com/somefeed.rss";
reader.DataBind();
}
</script>
<wilco:RssReader ID="reader" Runat="server">
<ItemTemplate>Title: <%# ((DataRowView)Container.DataItem)["title"]) %>.<br /></ItemTemplate>
</wilco:RssReader>
|
License:
This project is released under Ms-PL. Please contact me directly for questions or exceptions.
Downloads:
Requirements: