📄 sectionedit.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 SectionEdit : UserControl
{
protected ValuedTextBox subjectTextBox;
protected ValuedCheckBox enabledCheckBox;
protected ValuedDropDownList groupDropDownList;
protected ResourceButton saveButton;
protected override void OnLoad(EventArgs e)
{
if (!Page.IsPostBack && !AjaxManager.IsCallBack)
{
BindData();
}
saveButton.Click += new EventHandler(SaveSection);
}
private void BindData()
{
if (groupDropDownList != null)
{
groupDropDownList.DataSource = BusinessManager.GetGroupList(RequestBuilder.BuildGroupListRequest());
groupDropDownList.DataTextField = "Subject";
groupDropDownList.DataValueField = "EntityId";
groupDropDownList.DataBind();
}
Section section = BusinessManager.GetSection(WebContext.Current.EntityId);
if (section != null)
{
subjectTextBox.Value = section.Subject;
enabledCheckBox.Checked = section.Enabled == 1 ? true : false;
groupDropDownList.Value = section.GroupId.ToString();
}
}
private void SaveSection(object sender, EventArgs e)
{
Section section = BusinessManager.GetSection(WebContext.Current.EntityId);
if (section != null)
{
section.GroupId = int.Parse(groupDropDownList.Value);
section.Enabled = enabledCheckBox.Checked ? 1 : 0;
section.Subject = subjectTextBox.Value;
BusinessManager.UpdateSection(section);
}
Page.Response.Redirect(SiteUrls.Instance().GetSectionListUrl(section.GroupId));
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -