content_list.aspx.cs
来自「具有一般blog的相册、文章、作品等功能程序结构也比较清晰采用三层结构开发(利用」· CS 代码 · 共 144 行
CS
144 行
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using liuwei.FrameWork.DB;
namespace liuwei
{
/// <summary>
/// content_list 的摘要说明。
/// </summary>
public class content_list : System.Web.UI.Page
{
private string bigTypeID;
private string smallTypeID;
protected System.Web.UI.WebControls.Repeater rpList;
protected System.Web.UI.WebControls.Repeater rpType;
protected System.Web.UI.WebControls.Literal lbTypeInfo;
protected System.Web.UI.WebControls.Literal lbTypeInfo1;
protected System.Web.UI.WebControls.Literal lbBigTypeInfo;
protected System.Web.UI.WebControls.Literal lbMonth;
protected System.Web.UI.WebControls.Literal lbYear;
private void Page_Load(object sender, System.EventArgs e)
{
// 在此处放置用户代码以初始化页面
bigTypeID = Request.QueryString["bigtypeid"];
smallTypeID = Request.QueryString["smalltypeid"];
//不显示小类,只显示大类
if (smallTypeID==null||smallTypeID==""||smallTypeID=="0")
{
DataTable dt = DbProvider.Instance().GetContentList(Convert.ToInt32(bigTypeID),0,15);
rpList.DataSource = dt;
rpList.DataBind();
dt.Clear();
dt.Dispose();
}
else
{
DataTable dt = DbProvider.Instance().GetContentList(0,Convert.ToInt32(smallTypeID),15);
rpList.DataSource = dt;
rpList.DataBind();
dt.Clear();
dt.Dispose();
//当前所显示的类别的信息
DataTable dtTypeInfo=DbProvider.Instance().GetSmallTypeInfo(Convert.ToInt32(smallTypeID));
lbTypeInfo.Text = dtTypeInfo.Rows[0]["smalltypename"].ToString();
lbTypeInfo1.Text = dtTypeInfo.Rows[0]["smalltypename"].ToString();
dtTypeInfo.Clear();
dtTypeInfo.Dispose();
}
//在目录中显示小类别
DataTable dtType=DbProvider.Instance().GetContentType(Convert.ToInt32(bigTypeID));
rpType.DataSource = dtType;
rpType.DataBind();
dtType.Clear();
dtType.Dispose();
//大类名
DataTable dtBigType=DbProvider.Instance().GetBigTypeInfo(Convert.ToInt32(bigTypeID));
lbBigTypeInfo.Text = dtBigType.Rows[0]["bigtypename"].ToString();
if (lbTypeInfo1.Text=="")
{
lbTypeInfo1.Text = dtBigType.Rows[0]["bigtypename"].ToString();
}
if (lbTypeInfo.Text=="")
{
lbTypeInfo.Text = dtBigType.Rows[0]["bigtypename"].ToString() + " Updates";
}
dtBigType.Clear();
dtBigType.Dispose();
if (!Page.IsPostBack)
{
//建立一个临时变量
string tempUrl;
if (smallTypeID==null||smallTypeID=="")
{
tempUrl=bigTypeID + ",0,";
}
else
{
tempUrl=bigTypeID + "," + smallTypeID + ",";
}
//按月份查询
for (int i=DateTime.Now.Month-5;i<=DateTime.Now.Month;i++)
{
if (i>0)
{
lbMonth.Text = "<li><a href=\"content_list_month," + tempUrl + DateTime.Now.Year + "," + i + ".aspx\">" + DateTime.Now.Year + "/" + i + "</a></li>" + lbMonth.Text;
}
else
{
int i_y=DateTime.Now.Year-1;
int i_m=12+i;
lbMonth.Text = "<li><a href=\"content_list_month," + tempUrl + i_y + "," + i_m + ".aspx\">" + i_y + "/" + i_m + "</a></li>" + lbMonth.Text;
}
}
//按年查询
for (int i=DateTime.Now.Year-2;i<=DateTime.Now.Year;i++)
{
lbYear.Text = "<li><a href=\"content_list_year," + tempUrl + i + ".aspx\">" + i + "</a> <a href=\"rss_year," + tempUrl + i + ".aspx\" target=\"_blank\"><img src=\"images/xml.gif\" alt=\"\" /></a></li>" + lbYear.Text;
}
}
}
#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 + =
减小字号Ctrl + -
显示快捷键?