📄 recommendthreads.cs
字号:
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 + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -