📄 contenteditpage.cs
字号:
namespace ASPNET.StarterKit.Communities {
using System;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
public abstract class ContentEditPage : SkinnedCommunityControl {
protected Button btnAdd;
protected Button btnEdit;
protected Button btnPreview;
protected Button btnContinue;
protected Panel pnlPreview;
protected Panel pnlForm;
protected Panel pnlTopics;
public event SkinLoadEventHandler SkinLoad;
public event SubmitEventHandler Submit;
public event PreviewEventHandler Preview;
public event ContinueEventHandler Continue;
string _sectionContent = "Not Specified";
//*********************************************************************
//
// ContentAddPage Constructor
//
// Calls the base SkinnedCommunityControl constructor
// and assigns the default page skin. Also checks whether
// current user has permissions to add a book.
//
//*********************************************************************
public ContentEditPage() : base() {
if (!objUserInfo.MayEdit)
CommunityGlobals.ForceLogin();
}
//*********************************************************************
//
// OnInit Method
//
// Make sure that the content of the section matches the content of
// the page. Otherwise, the user is trying something sneaky.
//
//*********************************************************************
protected override void OnInit(EventArgs e) {
if (objSectionInfo.Content != _sectionContent)
throw new Exception(String.Format("Section content {0} does not match {1}!", objSectionInfo.Content, _sectionContent));
}
//*********************************************************************
//
// SectionContent Property
//
// Specifies the type of content contained in this section.
//
//*********************************************************************
protected string SectionContent {
get { return _sectionContent;}
set { _sectionContent = value; }
}
//*********************************************************************
//
// SkinType Property
//
// Specifies the skins directory where this page's skin file is located.
//
//*********************************************************************
override protected string SkinType {
get { return "ContentSkins"; }
}
//*********************************************************************
//
// InitializeSkin Method
//
// Retrieves all the controls from the page skin.
//
//*********************************************************************
override protected void InitializeSkin(Control skin) {
// Find and hide Add Button
btnAdd = (Button)GetOptionalControl(skin, "btnAdd");
if (btnAdd != null)
btnAdd.Visible = false;
// Find Edit Button
btnEdit = (Button)GetControl(skin, "btnEdit");
btnEdit.Click += new EventHandler(OnSubmit);
// Find Topics Panel
pnlTopics = (Panel)GetOptionalControl(skin, "pnlTopics");
if (pnlTopics != null)
if (!objSectionInfo.EnableTopics)
pnlTopics.Visible = false;
// Find Preview Panel
pnlPreview = (Panel)GetOptionalControl(skin, "pnlPreview");
if (pnlPreview != null) {
// Find Form Panel
pnlForm = (Panel)GetControl(skin, "pnlForm");
// Find Preview Button
btnPreview = (Button)GetControl(skin, "btnPreview");
btnPreview.Click += new EventHandler(OnPreview);
// Find Continue Button
btnContinue = (Button)GetControl(skin, "btnContinue");
if (btnContinue != null) {
btnContinue.CausesValidation = false;
btnContinue.Click += new EventHandler(OnContinue);
}
// Hide the Preview Panel on first load
if (!Page.IsPostBack)
pnlPreview.Visible = false;
}
// Call Skin Load event
OnSkinLoad(this, new SkinLoadEventArgs(skin));
}
protected virtual void OnSkinLoad(Object s, SkinLoadEventArgs e){
if (SkinLoad != null)
SkinLoad(s, e);
}
protected virtual void OnSubmit(Object s, EventArgs e){
if (Submit != null)
Submit(s, EventArgs.Empty);
}
protected virtual void OnPreview(Object s, EventArgs e){
if (Page.IsValid) {
pnlForm.Visible = false;
pnlPreview.Visible = true;
if (Preview != null)
Preview(s, e);
}
}
protected virtual void OnContinue(Object s, EventArgs e){
pnlForm.Visible = true;
pnlPreview.Visible = false;
if (Continue != null)
Continue(s, e);
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -