Twitter module in ASP.NET for download
If you've been looking for an ASP.NET Twitter module, look no further. I've coded a C# module in order to consume a given Twitter feed. Download the Twitter module for easy use in your own project.
How to use
You can either show the latest Twitter message or any given number of Twitter messages with this module - all you have to do is to point out a Twitter username and the number of messages to show.
Here's a code example on how you can show 5 Twitter messages in a Repeater.
Code-behind:
string userName = "dileno";
List<TwitterFeed> messages = TwitterFeed.Fetch(userName, 5);
if (messages.Count>0)
{
rptTwitterMessages.DataSource = messages;
rptTwitterMessages.DataBind();
}
Repeater in code-front (aspx/ascx):
<asp:Repeater ID="rptTwitterMessages" runat="server">
<HeaderTemplate><ul></HeaderTemplate>
<FooterTemplate></ul></FooterTemplate>
<ItemTemplate><li><%#((TwitterFeed)Container.DataItem).Message %> (<a href="<%#((TwitterFeed)Container.DataItem).Link %>"><%#((TwitterFeed)Container.DataItem).PubDate %></a>)</li></ItemTemplate>
</asp:Repeater>
Download the Twitter module
You can download the C# module with complete source code and code examples:
(zip, 16 kB)
Short instructions for implementation
- Drop the TwitterFeed.cs file into your project.
- Use the code in Default.aspx.cs to customize the Twitter messages.
- Update your appSettings.Config with the key TwitterFeedUrl, which you find in this project's appSettings.Config file.