⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 article.ascx.cs

📁 ASP.net网站开发四“酷”全书:新闻、论坛、电子商城、博客_源码
💻 CS
字号:
namespace WesternByte.MyBlog.Controls.Blog
{
	using System;
	using System.Data;
	using System.Drawing;
	using System.Web;
	using System.Web.UI.WebControls;
	using System.Web.UI.HtmlControls;
	using WesternByte.MyBlog.Core.Category;
	using WesternByte.MyBlog.Core.Article;

	/// <summary>
	///		Article 的摘要说明。
	/// </summary>
	public class Article : System.Web.UI.UserControl
	{
		protected System.Web.UI.WebControls.DataList articleCategory;
		protected System.Web.UI.WebControls.DataList articleDoc;
		protected System.Web.UI.HtmlControls.HtmlTable anoCount;
		protected System.Web.UI.HtmlControls.HtmlTable adnoCount;
		protected CategoryDAO cDAO = new CategoryDAO();
		protected ArticleDAO aDAO = new ArticleDAO();

		private void Page_Load(object sender, System.EventArgs e)
		{
			// 在此处放置用户代码以初始化页面
			int BlogID = Convert.ToInt32(Page.Request.QueryString["BlogID"]);
			DataSet acDs = cDAO.LoadList(BlogID,"a");
			acDs.Tables[0].Columns.Add("CategoryStr");
			for(int i=0;i<acDs.Tables[0].Rows.Count;i++)
			{
				acDs.Tables[0].Rows[i]["CategoryStr"] = "<a href=\"Article.aspx?BlogID=" + BlogID + "&CategoryID=" + acDs.Tables[0].Rows[i]["CategoryID"].ToString() + "\">" + acDs.Tables[0].Rows[i]["Name"].ToString() + "&nbsp;(" + aDAO.LoadCount(BlogID,Convert.ToInt32(acDs.Tables[0].Rows[i]["CategoryID"].ToString()),"","") + ")</a>";
			}
			articleCategory.DataSource = acDs.Tables[0].DefaultView;
			articleCategory.DataBind();
			if(acDs.Tables[0].Rows.Count==0)
			{
				anoCount.Visible = true;
			}
			else
			{
				anoCount.Visible = false;
			}
			DataSet adDs = aDAO.LoadMonth(BlogID);
			adDs.Tables[0].Columns.Add("Doc");
			for(int i=0;i<adDs.Tables[0].Rows.Count;i++)
			{
				adDs.Tables[0].Rows[i]["Doc"] = "<a href=\"Article.aspx?BlogID=" + BlogID + "&Doc=" + adDs.Tables[0].Rows[i]["Time"].ToString() + "\">" + adDs.Tables[0].Rows[i]["Time"].ToString().Substring(0,4) + "年" + Convert.ToInt32(adDs.Tables[0].Rows[i]["Time"].ToString().Substring(5)) + "月&nbsp;(" + adDs.Tables[0].Rows[i]["Count"].ToString() + ")</a>";
			}
			articleDoc.DataSource = adDs.Tables[0].DefaultView;
			articleDoc.DataBind();
			if(adDs.Tables[0].Rows.Count==0)
			{
				adnoCount.Visible = true;
			}
			else
			{
				adnoCount.Visible = false;
			}
		}

		#region Web 窗体设计器生成的代码
		override protected void OnInit(EventArgs e)
		{
			//
			// CODEGEN: 该调用是 ASP.NET Web 窗体设计器所必需的。
			//
			InitializeComponent();
			base.OnInit(e);
		}
		
		/// <summary>
		///		设计器支持所需的方法 - 不要使用代码编辑器
		///		修改此方法的内容。
		/// </summary>
		private void InitializeComponent()
		{
			this.Load += new System.EventHandler(this.Page_Load);

		}
		#endregion
	}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -