📄 postlist.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 PostList : UserControl
{
protected Repeater list;
protected Pager pager;
protected CurrentPage currentPage;
protected override void OnLoad(EventArgs e)
{
if (!Page.IsPostBack && !AjaxManager.IsCallBack)
{
BindData();
}
AjaxManager.Register(this, "AjaxMethod");
}
private void BindData()
{
if (list == null)
{
return;
}
EntityList posts = BusinessManager.GetPostList(RequestBuilder.BuildPostListRequest(WebContext.Current.ParentId, pager.PageIndex, pager.PageSize));
list.DataSource = posts;
list.DataBind();
if (pager != null && currentPage != null)
{
pager.TotalPages = pager.CalculateTotalPages(posts.TotalCount);
currentPage.TotalRecords = posts.TotalCount;
currentPage.TotalPages = pager.TotalPages;
currentPage.PageIndex = pager.PageIndex;
}
}
#region Ajax Method
[AjaxMethod(IncludeControlValuesWithCallBack = false)]
public void DeletePost(int postId)
{
BusinessManager.DeletePost(postId);
Thread thread = BusinessManager.GetThread(RequestBuilder.BuildThreadOnlyRequest(WebContext.Current.ParentId)) as Thread;
if (thread != null)
{
thread.TotalPosts--;
Entities.UpdateEntity(thread);
}
}
[AjaxMethod(IncludeControlValuesWithCallBack = false)]
public void DeletePosts(string postIds)
{
if (string.IsNullOrEmpty(postIds))
{
return;
}
string[] postIdArray = postIds.Split(new char[] { ':' }, StringSplitOptions.RemoveEmptyEntries);
int postId = 0;
foreach (string stringPostId in postIdArray)
{
try
{
postId = Int32.Parse(stringPostId);
}
catch
{
continue;
}
if (postId > 0)
{
DeletePost(postId);
}
}
}
#endregion
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -