recommendthreads.cs
来自「ASP.NET简洁论坛源代码 这是一个简单的论坛」· CS 代码 · 共 84 行
CS
84 行
using System;
using System.Collections.Generic;
using System.Text;
using System.ComponentModel;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using NetFocus.Web.Core;
namespace NetFocus.Web.Applications.Forum
{
public class RecommendThreads : UserControl, IPageIndexChangedEventHandler
{
protected Repeater list;
protected AjaxPager pager;
WebContext context = WebContext.Current;
private int SectionId
{
get
{
object o = ViewState["SectionId"];
if (o != null)
{
return int.Parse(o.ToString());
}
return 0;
}
set
{
ViewState["SectionId"] = value;
}
}
protected override void OnLoad(EventArgs e)
{
this.ID = pager.TargetControlID;
if (!Page.IsPostBack)
{
SectionId = context.SectionId;
BindData(pager.PageIndex, pager.PageSize);
}
AjaxManager.Register(this, "AjaxMethod");
}
public void BindData(int pageIndex, int pageSize)
{
if (list == null)
{
return;
}
EntityList threads = BusinessManager.GetThreadList(RequestBuilder.BuildRecommendThreadListRequest(this.SectionId, pageIndex - 1, pageSize));
list.DataSource = threads;
list.DataBind();
pager.TotalRecords = threads.TotalCount;
}
#region Ajax Method
[AjaxMethod(IncludeControlValuesWithCallBack = false)]
public void DeleteThread(int threadId)
{
Thread thread = BusinessManager.GetThread(RequestBuilder.BuildThreadRequest(threadId)) as Thread;
BusinessManager.DeleteThread(threadId);
//更新版块回复总数
Section section = BusinessManager.GetSection(thread.SectionId);
if (section != null)
{
section.TotalThreads--;
BusinessManager.UpdateSection(section);
}
}
#endregion
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?