码迷,mamicode.com
首页 > 其他好文 > 详细

RSS

时间:2014-11-18 23:46:31      阅读:267      评论:0      收藏:0      [点我收藏+]

标签:des   style   http   io   ar   color   os   sp   for   

前台:

  

<?xml version="1.0"?>
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="RSS.aspx.cs" Inherits="RSS" ContentType="text/xml" %>

<rss version="2.0">
<channel>
<title>XXX网站书店</title>
<description></description>
<link>http://www.bookshop.com</link>
<language>zh-cn</language>
<docs></docs>
<ttl>5</ttl>

<asp:Repeater runat="server" ID="RepeaterRss">
<ItemTemplate>
<item>
<title><%#Eval("Title") %></title>
<link><%#Eval("Id","http://localhost:8088/BookDetail.aspx?id={0}") %></link>
<pubDate><%#Eval("PublishDate") %></pubDate>
<source>XXX网站书店</source>
<author><%#Eval("Author") %></author>
<description><![CDATA[<%#Eval("ContentDescription") %>]]></description>
</item>
</ItemTemplate>
</asp:Repeater>


</channel>
</rss>

 

 

后台:

public partial class RSS : System.Web.UI.Page
{
  protected void Page_Load(object sender, EventArgs e)
  {
    LoadRssData();
  }

  private void LoadRssData()
  {
    List<Books> lst = new List<Books>();
    for (int i = 0; i < 15; i++)
    {
       lst.Add(new Books() { Id=i+1, Title="标题"+(i+1), Author="秋月光璇", ContentDescription="详细内容:"+Guid.NewGuid().ToString(), PublishDate=DateTime.Now});
    }
    this.RepeaterRss.DataSource = lst;
    this.RepeaterRss.DataBind();
  }

}

 

 

public class Books
{
  public Books()
  { }

  public int Id { get; set; }
  public string Title { get; set; }
  public string Author { get; set; }
  public DateTime PublishDate { get; set; }
  public string ContentDescription { get; set; }
}

 

RSS

标签:des   style   http   io   ar   color   os   sp   for   

原文地址:http://www.cnblogs.com/qiuyueguangxuan/p/4106661.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!