The contents of this post has been moved to here. Please visit the link to view the contents.
Sorry for the inconvenience.
Thanks!
All Day, I Dream about Codes
Does anyone noticed this?
http://www.mozilla.com/en-US/firefox/ie.html
See, the courage, confidence and power of Mozilla corporation; directly advertising over IE. Nothing to say more, IE market-share dipped to 66%. But, this time IE is losing the market-share in a quicker pace. IE8 have to struggle a lot to gain the market again and again.
Good luck, IE.
BTW, I’m an addicted IE user.
Just imagine you’ve five fields (columns) in table & you only want to insert 2 values (say, in Col2 & Col3) of the table; then use as follows:
1: INSERT INTO Table_Name (Col2_Name, Col3_Name)
2: VALUES (Col2_Value, Col3_Value)
An awesome RSS Feed control (Dmitry’s RSSToolkit) was released years before, I came to knew about ASP.NET.
Last months, I’s spending some time with the control. I must say, its really cool. One problem I encountered; lack of documentation (or my lack of knowledge), What ever it may. But, it was really nice to write some cool codes using the control.
Ok! In this article, I’ll show small piece of codes demonstrating how to retrieve RSS Feeds from sites programmatically.
Before we start, please download RSSToolkit 2.0 from codeplex, and add the control to your Visual Studio toolbox (?).
Step 1: Drag-drop ‘RssDataSource’ control from your toolbox to the webpage.
Now just keep an eye on the source-view. When you drag-drop the RssDataSource, you’ll get a Register tag in the source-view like:
<%@ Register assembly="RssToolkit" namespace="RssToolkit.Web.WebControls" tagprefix="cc1" %>
Step 2: Drag-drop a TextBox for accepting the feed-url.
Step 3: Drag-drop a Button to trigger fetching the feeds. Double-Click the button to generate the Click event.
Step 4: Drag-drop a Label control to show an error when you enter an invalid feed-url.
[Design-View]
[Source-View]
<body>
<form id="form1" runat="server">
<div>
<cc1:RssDataSource ID="RssDataSource1" runat="server">
</cc1:RssDataSource>
<br />
Enter Feed URL: <asp:TextBox ID="TextBox1" runat="server" Width="300px"></asp:TextBox>
<asp:Button ID="Button1" runat="server" onclick="Button1_Click" Text="Fetch" />
<br />
<asp:Label ID="Label1" runat="server" Font-Bold="True" ForeColor="#FF3300"></asp:Label>
</div>
</form>
</body>
[Code-View]
using RssToolkit.Rss;
// Fecth RSS
protected void Button1_Click(object sender, EventArgs e)
{
string feedData = string.Empty;
// Accepts Feed URL
RssDataSource1.Url = TextBox1.Text.Trim();
try
{
// Iterate through the RSS feed Items
foreach (RssItem item in RssDataSource1.Rss.Channel.Items)
{
// Feed Author
feedData = item.Author;
// Feed Title
feedData = item.Title;
// Feed Link
feedData = item.Link;
// Feed Description
feedData = item.Description;
// Feed Publish Date
feedData = item.PubDate;
// Print the output
Response.Write(feedData + "<br/><hr/><br/>");
}
}
catch (UriFormatException exp)
{
Label1.Text = "Invalid Feed URL";
}
}
[Demonstration]
a) copy the url of an RSS feed, say http://feeds2.feedburner.com/DidYouSaynet.
b) Paste it on the TextBox & Hit the button. That's all.
c) See How the feeds are displayed.
Hoping it will help someone.
Note:
a) Do not forget to include the namespace using RSSToolkit.RSS.
b) One of the common question you may encounter is how to fetch feeds with a count limit?. That means you only want to fetch last 3 feeds, 5 feeds, etc. At this point I don't have the answer. Even though the RSSDataSource has a property named MaxItems ( where you can set the feed limit), it was not working when tried programmatically. Only way I believe you can do; is to insert a count value in the foreach statement & break the loop when you feed-count limit is reached.
c) Next question will be how can I download updated feeds only from a site?. The answer will be my next post.
Also you can find some cool articles of RSSToolkit @ ScottGu’s blog and @ CodeProject, which inspired me to write this.
Thanks for taking time to read the post.
The contents of this post has been moved to http://blogs.cametoofar.com/post/Adding-Controls-to-Visual-Studio-Toolbox.aspx.
Sorry for inconvenience.
Thanks