前台文件: /><%@ Page language="c#" Codebehind="podcast.aspx.cs" ContentType="text/xml" AutoEventWireup="false" Inherits="WebApplicationwotiankeji.asp.procast" %><?xml version="1.0" encoding="GB2312"?><rss version="2.0"><asp:Repeater id="reapter_blog_programe" runat="server"><HeaderTemplate> <channel> <title> <%Response.Write(str_blog_name);%> </title> <link> http://www.lifepop.com/myradio.aspx?domain=<%Response.Write(str_blog_links);%></link> <description> <%Response.Write(str_blog_description);%> </description> <copyright>http://www.lifepop.com</copyright> <generator>www.lifepop.com Podcast System</generator> <webMaster>lifepop@hotmail.com</webMaster></HeaderTemplate><ItemTemplate><asp:Label Runat=server ID=programeid Text='<%# DataBinder.Eval(Container.DataItem,"program_id")%>' visible=false></asp:Label> <item> <title><![CDATA[<%# FormatForXML(DataBinder.Eval(Container.DataItem,"p_title"))%>]]></title> <link>http://www.lifepop.com/myradio.aspx?castid=<%# DataBinder.Eval(Container.DataItem,"program_id")%></link> <author><%Response.Write(str_blog_user);%></author> <pubDate><%# DataBinder.Eval(Container.DataItem,"p_public_time")%></pubDate> <description><![CDATA[<%# FormatForXML(DataBinder.Eval(Container.DataItem,"p_content"))%>]]></description> <asp:Repeater id="repeater_programe_url" runat="server"> <ItemTemplate> <enclosure url="<%# DataBinder.Eval(Container.DataItem,"my_url")%>" length="" type="audio/mpeg" /> </ItemTemplate> </asp:Repeater> </item> </ItemTemplate><FooterTemplate> </channel></FooterTemplate></asp:Repeater></rss>
后台文件:using System;using System.Collections;using System.ComponentModel;using System.Data;using System.Data.SqlClient;using System.Drawing;using System.Web;using System.Web.SessionState;using System.Web.UI;using System.Web.UI.WebControls;using System.Web.UI.HtmlControls;
namespace WebApplicationwotiankeji.asp{ /// <summary> /// procast 的摘要说明。 /// </summary> public class procast : System.Web.UI.Page { protected System.Web.UI.WebControls.Repeater reapter_blog_programe; protected System.Web.UI.WebControls.Repeater repeater_programe_url; public string str_blog_user=string.Empty; //播客电台的主人 public string str_blog_name=string.Empty; //播客名称 public string str_domain_name=string.Empty; public string str_blog_links=string.Empty; //播客连接 public string str_blog_description=string.Empty; //播客描述 private void Page_Load(object sender, System.EventArgs e) { // 在此处放置用户代码以初始化页面 str_domain_name=Request.Params["domain"]; str_domain_name="test"; // 在此处放置用户代码以初始化页面 select_blog_info(str_domain_name); select_programe_by_domain_name(str_domain_name); } private void select_blog_info(string str_parameter) { SqlConnection myConnection = new SqlConnection(System.Configuration.ConfigurationSettings.AppSettings["ConnectionSqlServer"]); string str_sql="select r_name,r_name,r_username,r_about,r_domain_name from user_radio_info where r_domain_name=@domain_name"; SqlCommand mysqlcommand = new SqlCommand(str_sql,myConnection); mysqlcommand.CommandType = CommandType.Text; mysqlcommand.CommandText=str_sql; mysqlcommand.Parameters.Add("@domain_name",SqlDbType.NVarChar,100); mysqlcommand.Parameters["@domain_name"].value="/str_domain_name; myConnection.Open(); SqlDataReader" mydatareader=mysqlcommand.ExecuteReader(); while(mydatareader.Read()) { str_blog_name=Convert.ToString(mydatareader["r_name"]); str_blog_links=Convert.ToString(mydatareader["r_domain_name"]); str_blog_description=Convert.ToString(mydatareader["r_about"]); str_blog_user=Convert.ToString(mydatareader["r_username"]); } mydatareader.Close(); myConnection.Close(); } //查询节目 private void select_programe_by_domain_name(string str_domain_name) { SqlConnection myConnection = new SqlConnection(System.Configuration.ConfigurationSettings.AppSettings["ConnectionSqlServer"]); string str_sql="select top 10 program_info.p_public_time,program_info.p_content,program_info.p_title,program_info.program_id from program_info where program_info.u_domain_name=@domain_name and(program_info.p_big_class=2 or program_info.p_big_class=3 or program_info.p_big_class=4) order by program_info.program_id desc"; SqlCommand mysqlcommand = new SqlCommand(str_sql,myConnection); mysqlcommand.CommandType = CommandType.Text; mysqlcommand.CommandText=str_sql; mysqlcommand.Parameters.Add("@domain_name",SqlDbType.NVarChar,100); mysqlcommand.Parameters["@domain_name"].value="/str_domain_name; myConnection.Open(); SqlDataReader" mydatareader=mysqlcommand.ExecuteReader(); reapter_blog_programe.DataSource=mydatareader; reapter_blog_programe.DataBind(); myConnection.Close(); } public string FormatForXML(object input) { string data = input.ToString(); // cast the input to a string
// replace those characters disallowed in XML documents data = data.Replace("&", "&"); data = data.Replace("/"", """); data = data.Replace("'", "'"); data = data.Replace("<", "<"); data = data.Replace(">", ">");
return data; } //模板绑定 private void reapter_blog_programe_ItemDataBound(object sender, System.Web.UI.WebControls.RepeaterItemEventArgs e) { if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem) { Label lblTypeID = lblTypeID =(Label)e.Item.FindControl("programeid"); ; Repeater rptProduct = (Repeater) e.Item.FindControl("repeater_programe_url"); SqlConnection myConnection = new SqlConnection(System.Configuration.ConfigurationSettings.AppSettings["ConnectionSqlServer"]); string str_sql="select my_url from myprograme_info where my_pr_id=@int_pid"; SqlCommand mysqlcommand = new SqlCommand(str_sql,myConnection); mysqlcommand.CommandType = CommandType.Text; mysqlcommand.CommandText=str_sql; mysqlcommand.Parameters.Add("@int_pid",SqlDbType.Int); mysqlcommand.Parameters["@int_pid"].value="/Convert.ToInt32(lblTypeID.Text.Trim()); myConnection.Open(); //Response.Write(str_sql); //Response.End(); " SqlDataReader mydatareader1=mysqlcommand.ExecuteReader(); rptProduct.DataSource =mydatareader1; rptProduct.DataBind(); myConnection.Close(); }
} #region Web 窗体设计器生成的代码 override protected void OnInit(EventArgs e) { // // CODEGEN: 该调用是 ASP.NET Web 窗体设计器所必需的。 // InitializeComponent(); base.OnInit(e); } /// <summary> /// 设计器支持所需的方法 - 不要使用代码编辑器修改 /// 此方法的内容。 /// </summary> private void InitializeComponent() {
this.reapter_blog_programe.ItemDataBound += new System.Web.UI.WebControls.RepeaterItemEventHandler(this.reapter_blog_programe_ItemDataBound); this.Load += new System.EventHandler(this.Page_Load);
} #endregion
}}