📄 sectionlist.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 SectionList : UserControl
{
protected Repeater list;
protected ValuedDropDownList groupDropDownList;
protected override void OnLoad(EventArgs e)
{
if (!Page.IsPostBack && !AjaxManager.IsCallBack)
{
BindData();
}
groupDropDownList.SelectedIndexChanged += new EventHandler(groupDropDownList_SelectedIndexChanged);
AjaxManager.Register(this, "AjaxMethod");
}
private void BindData()
{
if (groupDropDownList != null)
{
EntityList groups = BusinessManager.GetGroupList(RequestBuilder.BuildGroupListRequest());
Group topGroup = new Group();
topGroup.Subject = "所有版块组";
groups.Insert(0, topGroup);
groupDropDownList.DataSource = groups;
groupDropDownList.DataTextField = "Subject";
groupDropDownList.DataValueField = "EntityId";
groupDropDownList.DataBind();
if (WebContext.Current.GroupId > 0)
{
groupDropDownList.Value = WebContext.Current.GroupId.ToString();
}
}
if (list != null)
{
list.DataSource = BusinessManager.GetSectionList(RequestBuilder.BuildSectionListRequest(WebContext.Current.GroupId));
list.DataBind();
}
}
private void groupDropDownList_SelectedIndexChanged(object sender, EventArgs e)
{
list.DataSource = BusinessManager.GetSectionList(RequestBuilder.BuildSectionListRequest(int.Parse(groupDropDownList.SelectedValue)));
list.DataBind();
}
#region Ajax Method
[AjaxMethod(IncludeControlValuesWithCallBack = false)]
public void DeleteSection(int sectionId)
{
BusinessManager.DeleteSection(sectionId);
}
[AjaxMethod(IncludeControlValuesWithCallBack = false)]
public void DeleteSections(string articleCategoryIds)
{
if (string.IsNullOrEmpty(articleCategoryIds))
{
return;
}
string[] articleCategoryIdArray = articleCategoryIds.Split(new char[] { ':' }, StringSplitOptions.RemoveEmptyEntries);
int articleCategoryId = 0;
foreach (string stringArticleCategoryId in articleCategoryIdArray)
{
try
{
articleCategoryId = Int32.Parse(stringArticleCategoryId);
}
catch
{
continue;
}
if (articleCategoryId > 0)
{
DeleteSection(articleCategoryId);
}
}
}
#endregion
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -