⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 contentaddpage.cs

📁 一个ASP.NET下的中文内容管理和社区系统
💻 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 delegate void SkinLoadEventHandler(Object s, SkinLoadEventArgs e);
    public delegate void SubmitEventHandler(Object s, EventArgs e);
    public delegate void PreviewEventHandler(Object s, EventArgs e);
    public delegate void ContinueEventHandler(Object s, EventArgs e);


    public abstract class ContentAddPage : 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 ContentAddPage() : base() {
            if (!objUserInfo.MayAdd)
                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));
        }

        
        //*********************************************************************
        //
        // SkinType Property
        //
        // Specifies the skins directory where this page's skin file is located.
        //
        //*********************************************************************
        
        override protected string SkinType {
            get { return "ContentSkins"; }
        }
        

        //*********************************************************************
        //
        // SectionContent Property
        //
        // Specifies the type of content contained in this section.
        //
        //*********************************************************************
        
        protected string SectionContent {
            get { return _sectionContent;}
            set { _sectionContent = value; }
        }

        


        //*********************************************************************
        //
        // InitializeSkin Method
        //
        // Retrieves all the controls from the page skin.
        //
        //*********************************************************************

        override protected void InitializeSkin(Control skin) {

            // Find and hide Edit Button
            btnEdit = (Button)GetOptionalControl(skin, "btnEdit");
            if (btnEdit != null)
                btnEdit.Visible = false;
           
            // Find Add Button
            btnAdd = (Button)GetControl(skin, "btnAdd");
            btnAdd.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);
        }
        



    }
    
    public class SkinLoadEventArgs {
        Control _skin;
        
        public Control Skin {
            get {return _skin;}
        }
        
        public SkinLoadEventArgs(Control skin) {
            _skin = skin;
        }
    }
    
    
}

⌨️ 快捷键说明

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