Awesome ASP.NET 2.0 RSS Tool-Kit Released
page 2 of 8
by Scott Guthrie
Feedback
Average Rating: This article has not yet been rated.
Views (Total / Last 10 Days): 34129/ 83

RSS Data-binding Control Support

You can now declaratively databind any ASP.NET control to the new RSSDataSource control provided in the toolkit.  For example, to build a simple blog post aggregator for my blog you could follow the below steps with the free Visual Web Developer tool:

1) Create a new blank page

Figure 1

<img border=0 width=662 height=445src="/ArticleFiles/919/image001.jpg">

2) Drag/Drop the standard ASP.NET DataList control on the page, choose the “New DataSource” option from the smart-task:

Figure 2

 

3) Select the RSSDataSource control to bind to (note: this will automatically be populated in the datasource dialog window if the RSSDataSource control has been added to the VS toolbox):

Figure 3

4) In the RSSDataSource dialog that pops-up, type in the URL to the RSS feed you want to databind to:

Figure 4

5) The RSSDataSource control will then request the schema for the RSS feed and expose it to VS – which will then populate the <asp:datalist> control with an <itemTemplate> that is automatically populated with data-binding expressions for each of the RSS schema fields from the remote RSS source:

Figure 5

6) You can then switch into template editing mode in the WYSIWYG designer, or go into source-view to remove some of the fields and just leave the RSS fields you want to bind to.  Here is a sample page with a DataList template that binds to the link and title RSS item fields:

Listing 1

<%@ Register Assembly="RssToolkit" Namespace="RssToolkit" TagPrefix="RssToolkit"%>
<html>
<head runat="server">
    <title>ScottGu Feed</title>
</head>
<body>
    <form id="form1"runat="server">
    <div>
    
        <h2>ScottGu Blog Feed</h2>    
        
        <asp:DataList ID="DataList1"
runat="server" CellPadding="4"
DataSourceID="RssDataSource1" ForeColor="#333333">
            <ItemTemplate>
                <asp:HyperLink
ID="HyperLink1" runat="server" NavigateUrl='<%#
Eval("link")%>' Text='<%# Eval("title")%>'></asp:HyperLink>
            </ItemTemplate>
        </asp:DataList>
        
        <RssToolkit:rssdatasource
id="RssDataSource1" runat="server"
url="http://weblogs.asp.net/scottgu/Rss.aspx">
        </RssToolkit:rssdatasource>
 
    </div>
    </form>
</body>
</html>

7) I can then run the page and get this output:

Figure 6

As you can see above, the DataList is now bound to the data returned from the remote RSS feed on my site.

What is really cool is that the RSSDataSource control will cache the RSS data to avoid hitting it remotely on each request – so that you can efficiently add this type of blog aggregation functionality to your site and not have to worry about your performance slowing down.


View Entire Article

User Comments

Title: Jeff Paul Scam   
Name: Jeff Paul Scam
Date: 2009-03-04 8:28:42 PM
Comment:
This post gave us a major Brainstorm session of all the possibilities we can utilize on our blog.
Title: How to download the updated feeds?   
Name: Abhilash
Date: 2009-02-26 4:06:39 AM
Comment:
Hi,
Article was nice. I must say.

Do you missed something additional?I mean...how we download the updated feeds only?

Is such a feature missing in it ?

Looking forward for your response.
Thankz.
Title: Any VB   
Name: Stephanie
Date: 2008-05-21 10:20:24 AM
Comment:
I am looking for a VB version

Product Spotlight
Product Spotlight 





Community Advice: ASP | SQL | XML | Regular Expressions | Windows


©Copyright 1998-2024 ASPAlliance.com  |  Page Processed at 2024-04-25 4:27:57 AM  AspAlliance Recent Articles RSS Feed
About ASPAlliance | Newsgroups | Advertise | Authors | Email Lists | Feedback | Link To Us | Privacy | Search