sectionadd.cs

来自「这是一个简单的论坛程序源码」· CS 代码 · 共 54 行

CS
54
字号
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 SectionAdd : 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();
                if (WebContext.Current.GroupId > 0)
                {
                    groupDropDownList.Value = WebContext.Current.GroupId.ToString();
                }
            }
        }
        private void SaveSection(object sender, EventArgs e)
        {
            Section section = new Section();
            section.Subject = subjectTextBox.Value;
            section.Enabled = enabledCheckBox.Checked ? 1 : 0;
            section.GroupId = int.Parse(groupDropDownList.Value);
            BusinessManager.CreateSection(section);

            Page.Response.Redirect(SiteUrls.Instance().GetSectionListUrl(int.Parse(groupDropDownList.Value)));
        }

    }
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?