sectionedit.cs

来自「ASP.NET简洁论坛源代码 这是一个简单的论坛」· CS 代码 · 共 61 行

CS
61
字号
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 + =
减小字号Ctrl + -
显示快捷键?