topic.aspx.cs
来自「前台:asp.net;后台: sql server 一个功能完善的BBS系统源」· CS 代码 · 共 123 行
CS
123 行
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 Stella.Utility;
using System.Security.Permissions;
namespace Stella.Web.Pages
{
/// <summary>
/// topic 的摘要说明。
/// </summary>
public class topic : Container
{
protected System.Web.UI.WebControls.Label caption;
protected System.Web.UI.WebControls.Button go;
protected System.Web.UI.WebControls.Panel repPan;
protected System.Web.UI.WebControls.Repeater arts;
protected Wuqi.Webdiyer.AspNetPager pager;
protected Stella.Web.Controls.Reply rep;
private void Page_Load(object sender, System.EventArgs e)
{
if(!this.IsPostBack)
{
setUp(1);
}
if(this.isLogin)
repPan.Visible=true;
this.forumCounter.HitSum++;
}
#region Web 窗体设计器生成的代码
override protected void OnInit(EventArgs e)
{
//
// CODEGEN: 该调用是 ASP.NET Web 窗体设计器所必需的。
//
InitializeComponent();
base.OnInit(e);
}
/// <summary>
/// 设计器支持所需的方法 - 不要使用代码编辑器修改
/// 此方法的内容。
/// </summary>
private void InitializeComponent()
{
this.arts.ItemDataBound += new System.Web.UI.WebControls.RepeaterItemEventHandler(this.arts_ItemDataBound);
this.pager.PageChanged += new Wuqi.Webdiyer.PageChangedEventHandler(this.AspNetPager1_PageChanged);
this.go.Click += new System.EventHandler(this.go_Click);
this.Load += new System.EventHandler(this.Page_Load);
}
#endregion
private void setUp(int page)
{
Stella.Utility.DebugHelper.CheckCondition(Request["top"]!=null,"没有主题编号top传入topic.aspx页");
Stella.Utility.DebugHelper.CheckCondition(Request["tid"]!=null,"没有版块编号tid传入topic.aspx页");
Stella.Model.Topic top=new Stella.Model.Topic();
top.Tid=int.Parse(Request["top"]);
Stella.BusinessLogic.TopicLogic tl=new Stella.BusinessLogic.TopicLogic();
int count=tl.FillWithArts(top,Stella.Utility.ConfigHelper.TopicSize,page);
this.arts.DataSource=top.Arts;
this.arts.DataBind();
setPager(count,ConfigHelper.TopicSize,page);
string cap=(string)ViewState["caption"];
this.caption.Text=cap;
this.rep.Caption=cap;
//这个是为了向回复页传递caption值
Session["caption"]=cap;
}
private void setPager(int count,int size,int index)
{
pager.RecordCount=count;
pager.PageSize=size;
pager.CurrentPageIndex=index;
}
private void arts_ItemDataBound(object sender, System.Web.UI.WebControls.RepeaterItemEventArgs e)
{
Stella.Web.Controls.Art artBox=(Stella.Web.Controls.Art)e.Item.FindControl("artBox");
artBox.Value=(Stella.Model.Art)e.Item.DataItem;
if(ViewState["caption"]==null)
ViewState["caption"]=artBox.Value.Caption;
}
[PrincipalPermission(SecurityAction.Demand,Authenticated=true)]
private void go_Click(object sender, System.EventArgs e)
{
this.artLogic.Create(this.rep.Value);
Session.Remove("caption");
this.themeCounter[int.Parse(Request["tid"])].ArtSum++;
if(ViewState["page"]==null)
ViewState["page"]=1;
Response.Redirect(string.Format("topic.aspx?tid={0}&top={1}",Request["tid"],Request["top"]));
}
private void AspNetPager1_PageChanged(object src, Wuqi.Webdiyer.PageChangedEventArgs e)
{
ViewState["page"]=e.NewPageIndex;
setUp(e.NewPageIndex);
}
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?