📄 sectiongeneral.ascx.cs
字号:
namespace ASPNET.StarterKit.Communities.Admin.EditSections
{
using System;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
/// <summary>
/// Summary description for SectionGeneral.
/// </summary>
public abstract class SectionGeneral : System.Web.UI.UserControl
{
protected System.Web.UI.WebControls.RequiredFieldValidator RequiredFieldValidator1;
protected System.Web.UI.WebControls.TextBox txtName;
protected System.Web.UI.WebControls.RequiredFieldValidator RequiredFieldValidator2;
protected System.Web.UI.WebControls.TextBox txtTitle;
protected System.Web.UI.WebControls.RequiredFieldValidator RequiredFieldValidator3;
protected System.Web.UI.WebControls.TextBox txtMenuTitle;
protected System.Web.UI.WebControls.RequiredFieldValidator RequiredFieldValidator4;
protected ASPNET.StarterKit.Communities.LengthValidator LengthValidator1;
protected System.Web.UI.WebControls.TextBox txtDescription;
protected System.Web.UI.WebControls.RadioButtonList radlPageTypes;
protected System.Web.UI.WebControls.Panel pnlType;
protected System.Web.UI.WebControls.DropDownList dropParentSections;
protected System.Web.UI.WebControls.Panel pnlParentSection;
protected System.Web.UI.WebControls.CheckBox chkIsEnabled;
#region Web Form Designer generated code
override protected void OnInit(EventArgs e)
{
//
// CODEGEN: This call is required by the ASP.NET Web Form Designer.
//
InitializeComponent();
base.OnInit(e);
}
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.Load += new System.EventHandler(this.Page_Load);
}
#endregion
public SectionInfo Section;
public string Name {
get { return txtName.Text; }
}
public string Title {
get { return txtTitle.Text; }
}
public string MenuTitle {
get { return txtMenuTitle.Text; }
}
public string Description {
get { return txtDescription.Text; }
}
public bool IsEnabled {
get { return chkIsEnabled.Checked; }
}
public int PageType {
get { return Int32.Parse(radlPageTypes.SelectedItem.Value); }
}
public int SectionType {
get { return Int32.Parse(radlPageTypes.SelectedItem.Value); }
}
public int ParentSectionID {
get {
if (dropParentSections.SelectedIndex == -1)
return -1;
else
return Int32.Parse(dropParentSections.SelectedItem.Value);
}
}
//*********************************************************************
//
// Page_Load Method
//
// If we have Section info, then display it -- otherwise,
// assume adding new section.
//
//*********************************************************************
void Page_Load(object sender, System.EventArgs e) {
if (!IsPostBack) {
// Bind parents
if (Section != null) {
// Initialize values from SectionInfo object
txtName.Text = Section.Name;
txtTitle.Text = Section.Title;
txtMenuTitle.Text = Section.MenuTitle;
txtDescription.Text = Section.Description;
chkIsEnabled.Checked = Section.IsEnabled;
pnlType.Visible = false;
if (Section.ParentSectionID == -1)
pnlParentSection.Visible = false;
else {
dropParentSections.DataSource = SectionUtility.GetPossibleParents(Section.ID);
dropParentSections.DataTextField = "section_name";
dropParentSections.DataValueField = "section_id";
dropParentSections.DataBind();
}
// Assign default value (notice we loop since Parent might not exist)
string strParentID = Section.ParentSectionID.ToString();
foreach (ListItem item in dropParentSections.Items)
if (item.Value == strParentID)
item.Selected = true;
} else {
pnlType.Visible = true;
radlPageTypes.DataSource = SectionUtility.GetSectionPageTypes();
radlPageTypes.DataTextField = "pagetype_NameAndDescription";
radlPageTypes.DataValueField = "pagetype_id";
radlPageTypes.DataBind();
dropParentSections.DataSource = SectionUtility.GetPossibleParents(-1);
dropParentSections.DataTextField = "section_name";
dropParentSections.DataValueField = "section_id";
dropParentSections.DataBind();
// Set Default values
radlPageTypes.Items[0].Selected = true;
chkIsEnabled.Checked = true;
}
}
}
private void Page_Load()
{
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -