Display RSS Feeds as A Calendar
I really like this DataCalendar control that I found a while back and, even though it's a few years old, I keep finding new uses for it.
I'm working on this little project that includes a feature for posting events (live auctions in this case). The project includes syndicating the event list through RSS but, the people using it didn't really understand why that was cool. So, using the DataCalendar control, I created a little "look-at-what-RSS-can-do" demonstration that, to put it simply, "goes out to a bunch of auction web sites and copies all of the upcoming auctions to a calendar on my web site". Here's what the example looked like.
Feel free to tinker with the example by using an RSS feed of your own choosing. Just change the "test" parameter like in this example that loads some blogs from one of my other sites.
Before you get started, you need to download the DataCalendar control.
NOTE: I created this calendar to display in my CommunityServer-based site but, it should be pretty easy to pick out the CS stuff if you want it "plain vanilla".
In the Default.aspx...
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="Auctions_Default" %>
<%@ Register Assembly="DataCalendar" Namespace="DataControls" TagPrefix="cc1" %>
<%@ Register TagPrefix="CS" Namespace="CommunityServer.Controls" Assembly="CommunityServer.Controls" %>
<CS:MPContainer runat="server" id="Mpcontainer1" ThemeMasterFile="Master.ascx">
<CS:MPContent id="bcr" runat="server">
<div class="CommonContentArea">
<div class="CommonContent">
<CS:ContentPart runat="Server" contentname="CustomerAuctions" id="featuredContentPart"
text="<div class="CommonSidebarArea"><h4 class="CommonSidebarHeader">Featured Item</h4><div class="CommonSidebarContent">Content Management is easy in Community Server! <p>Sign-in with your Admin account and double-click to edit me!</p></div></div>" />
<cc1:DataCalendar ID="dcAuctions" ShowNextPrevMonth="true" BackColor="white" DayField="TaskDate"
Font-Names="verdana" NextPrevFormat="FullMonth" runat="server" Width="100%">
<SelectedDayStyle BackColor="ghostwhite" ForeColor="black" />
<OtherMonthDayStyle ForeColor="#999999" />
<NextPrevStyle Font-Size="10pt" Font-Underline="false" ForeColor="white" />
<DayHeaderStyle BackColor="lightgrey" ForeColor="black" Height="1px" />
<TitleStyle BackColor="black" Font-Bold="True" Font-Size="14pt" ForeColor="white"
Height="35px" />
<SelectorStyle BackColor="#99CCCC" ForeColor="#336666" />
<WeekendDayStyle BackColor="ghostWhite" />
<DayStyle HorizontalAlign="left" ForeColor="dimgray" VerticalAlign="top" />
<itemtemplate>
<a href="<%# Container.DataItem["link"] %>"
style="display:block; font-size:70%; margin:2px; padding:2px; text-transform:capitalize; border: 1px solid goldenrod; display:block; background-color:AntiqueWhite; text-decoration:none;"
title="Click for Details">
<%# Container.DataItem["Title"] %>
</itemtemplate>
<noeventstemplate>
<br /><br /><br /><br />
</noeventstemplate>
</cc1:DataCalendar>
</div>
</div>
</CS:MPContent>
</CS:MPContainer>
Then, wire it up (NOTE: this is just a bare example with no error handling):
In the Default.aspx.cs...
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Xml.XPath;
using System.Net;
public partial class Auctions_Default : CommunityServer.Components.CSPage
{
void Page_Load(object sender, EventArgs e)
{
RSSFeeds();
}
void RSSFeeds()
{
string[] aFeeds =
{
// Display the following feeds in the calendar
"http://nixonauctions.com/Feeds",
"http://michaelauction.com/Feeds",
"http://success-auctions.com/Feeds"
};
DataSet dta = new DataSet();
for (int i = 0; i < aFeeds.Length; i++)
{
// Loop through and add the feeds
HttpWebRequest feed =
HttpWebRequest.Create(aFeeds[i])
as HttpWebRequest;
DataSet ds = new DataSet();
ds.ReadXml(feed.GetResponse().GetResponseStream());
if (dta.Tables.Count == 0)
{ dta.Tables.Add(ds.Tables[2].Copy()); }
else
{ dta.Tables[0].Merge(ds.Tables[2].Copy()); }
ds.Clear();
}
dcAuctions.DataSource = dta.Tables[0];
dcAuctions.DataBind();
dcAuctions.DayField = "pubDate";
}
}
You could use this to aggregate and display select blogs, news columns, pictures, videos, etc. You may have to tweak the DataSet to adjust for different feed types, change some formatting, add some error handling but, if it's got an RSS feed, you can calenderize it.