Rss reader is quite good. I think if you put a lot of RSS modules in the form of igoogle or dropthings to display the information you need to pay attention to every day, it will reduce the time for you to open your browser and enter the URL. Let's take a look at the effect:
First, you need an ascx page to bind the content of the rss source to a ListView through an XDocument. The Code is as follows:
The Code is as follows:
Protected void Page_Load (object sender, EventArgs e)
{
// For demo purposes.
System. Threading. Thread. Sleep (1000 );
XDocument feedXML =
XDocument. Load ("http://feeds.feedsky.com/csdn.net/dujingjing1230 ");
Var feeds = from feed in feedXML. Descendants ("item ")
Select new
{
Title = feed. Element ("title"). Value,
Link = feed. Element ("link"). Value,
Description = feed. Element ("description"). Value
};
PostList. DataSource = feeds;
PostList. DataBind ();
}
The Code is as follows:
'> <% # Eval ("Title") %>
<% # Eval ("Description") %>
Next, you need to create An aspx page to display the RSS content. Of course, jQuery AJAX is used on this page to obtain the above data.
HTML page code:
Js that implements ajax:
The Code is as follows:
$ (Document). ready (function (){
$. Ajax ({
Type: "POST ",
Url: "RSSReader. asmx/GetRSSReader ",
Data :"{}",
ContentType: "application/json; charset = UTF-8 ",
DataType: "json ",
Success: function (msg ){
$ ('# Rsscontent'). removeClass ('loading ');
('{Rsscontent'{.html (msg. d );
}
});
});
Finally, the content of RSSReader. asmx web Services is as follows:
The Code is as follows:
Public class RSSReader: System. Web. Services. WebService {
[WebMethod]
Public string GetRSSReader ()
{
Page page = new Page ();
UserControl ctl =
(UserControl) page. LoadControl ("~ /RSSReaderControl. ascx ");
Page. Controls. Add (ctl );
StringWriter writer = new StringWriter ();
HttpContext. Current. Server. Execute (page, writer, false );
Return writer. ToString ();
}
}
The page also uses an image and will not be uploaded here.
Download Code:
Http://xiazai.jb51.net/200909/yuanma/RSSREader.rar