本文由中国C#技术学习中心整理 如果你对本文有不明之处请到技术论坛讨论! 1<%@ Page language="c#" Codebehind="RSS.aspx.cs" AutoEventWireup="false" Inherits="Socent.RSS" %>23--- RSS.aspx.cs45using System;6using System.Collections;7using System.ComponentModel;8using System.Data;9using System.Drawing;10using System.Web;11using System.Web.SessionState;12using System.Web.UI;13using System.Web.UI.WebControls;14using System.Web.UI.HtmlControls;1516namespace Socent17...{18 /**//// <summary>19 /// 取得聚合文章20 /// </summary>21 public class RSS : System.Web.UI.Page22 ...{23 Components.GenRSS gr = new Components.GenRSS(); // 实例化对象2425 string strRSS = "";2627 private void Page_Load(object sender, System.EventArgs e)28 ...{29 Response.ContentType = "application/xml"; // 输出并按xml数据显示30 Response.Write (GetRSS());31 }3233 /**//// <summary>34 /// 取得聚合文章35 /// </summary>36 public string GetRSS()37 ...{ 38 DataSet ds = gr.GenerateRSS(); // 调用GenerateRSS()方法,获得数据3940 strRSS = strRSS + "<rss version=\"2.0\">";41 strRSS = strRSS + "<channel>";42 strRSS = strRSS + "<title>土人制造</title>";43 strRSS = strRSS + "<link>http://www.socent.com</link>";44 strRSS = strRSS + "<description>土人制造</description>";45 for(int i = 0; i < ds.Tables[0].Rows.Count; i++)46 ...{47 strRSS = strRSS + "<item>";48 strRSS = strRSS + "<title><![CDATA["+ds.Tables[0].Rows[i]["Title"]+"]]></title>";49 strRSS = strRSS + "<link>http://www.socent.com/ArticleShow@"+ds.Tables[0].Rows[i]["ID"]+".html</link> ";50 strRSS = strRSS + "<description><![CDATA["+ds.Tables[0].Rows[i]["Description"]+"]]></description>";51 strRSS = strRSS + "<copyright>土人制造</copyright>";52 strRSS = strRSS + "<pubDate>"+Convert.ToDateTime(ds.Tables[0].Rows[i]["AddDate"].ToString()).ToString("yyyy-MM-dd HH:mm")+"</pubDate>";53 strRSS = strRSS + "<comments>http://www.socent.com/CommentShow@"+ds.Tables[0].Rows[i]["ID"]+".html</comments>";54 strRSS = strRSS + "</item>";55 }56 strRSS = strRSS + "</channel>";57 strRSS = strRSS + "</rss>";58 59 return strRSS;60 }6162 Web 窗体设计器生成的代码#region Web 窗体设计器生成的代码63 override protected void OnInit(EventArgs e)64 ...{65 //66 // CODEGEN: 该调用是 ASP.NET Web 窗体设计器所必需的。67 //68 InitializeComponent();69 base.OnInit(e);70 }71 72 /**//// <summary>73 /// 设计器支持所需的方法 - 不要使用代码编辑器修改74 /// 此方法的内容。75 /// </summary>76 private void InitializeComponent()77 ...{ 78 this.Load += new System.EventHandler(this.Page_Load);79 }80 #endregion81 }82} 本文由中国C#技术学习中心整理 如果你对本文有不明之处请到技术论坛讨论!
1<%@ Page language="c#" Codebehind="RSS.aspx.cs" AutoEventWireup="false" Inherits="Socent.RSS" %>23--- RSS.aspx.cs45using System;6using System.Collections;7using System.ComponentModel;8using System.Data;9using System.Drawing;10using System.Web;11using System.Web.SessionState;12using System.Web.UI;13using System.Web.UI.WebControls;14using System.Web.UI.HtmlControls;1516namespace Socent17...{18 /**//// <summary>19 /// 取得聚合文章20 /// </summary>21 public class RSS : System.Web.UI.Page22 ...{23 Components.GenRSS gr = new Components.GenRSS(); // 实例化对象2425 string strRSS = "";2627 private void Page_Load(object sender, System.EventArgs e)28 ...{29 Response.ContentType = "application/xml"; // 输出并按xml数据显示30 Response.Write (GetRSS());31 }3233 /**//// <summary>34 /// 取得聚合文章35 /// </summary>36 public string GetRSS()37 ...{ 38 DataSet ds = gr.GenerateRSS(); // 调用GenerateRSS()方法,获得数据3940 strRSS = strRSS + "<rss version=\"2.0\">";41 strRSS = strRSS + "<channel>";42 strRSS = strRSS + "<title>土人制造</title>";43 strRSS = strRSS + "<link>http://www.socent.com</link>";44 strRSS = strRSS + "<description>土人制造</description>";45 for(int i = 0; i < ds.Tables[0].Rows.Count; i++)46 ...{47 strRSS = strRSS + "<item>";48 strRSS = strRSS + "<title><![CDATA["+ds.Tables[0].Rows[i]["Title"]+"]]></title>";49 strRSS = strRSS + "<link>http://www.socent.com/ArticleShow@"+ds.Tables[0].Rows[i]["ID"]+".html</link> ";50 strRSS = strRSS + "<description><![CDATA["+ds.Tables[0].Rows[i]["Description"]+"]]></description>";51 strRSS = strRSS + "<copyright>土人制造</copyright>";52 strRSS = strRSS + "<pubDate>"+Convert.ToDateTime(ds.Tables[0].Rows[i]["AddDate"].ToString()).ToString("yyyy-MM-dd HH:mm")+"</pubDate>";53 strRSS = strRSS + "<comments>http://www.socent.com/CommentShow@"+ds.Tables[0].Rows[i]["ID"]+".html</comments>";54 strRSS = strRSS + "</item>";55 }56 strRSS = strRSS + "</channel>";57 strRSS = strRSS + "</rss>";58 59 return strRSS;60 }6162 Web 窗体设计器生成的代码#region Web 窗体设计器生成的代码63 override protected void OnInit(EventArgs e)64 ...{65 //66 // CODEGEN: 该调用是 ASP.NET Web 窗体设计器所必需的。67 //68 InitializeComponent();69 base.OnInit(e);70 }71 72 /**//// <summary>73 /// 设计器支持所需的方法 - 不要使用代码编辑器修改74 /// 此方法的内容。75 /// </summary>76 private void InitializeComponent()77 ...{ 78 this.Load += new System.EventHandler(this.Page_Load);79 }80 #endregion81 }82}