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

📄 deletecontentpage.cs

📁 ASP开发网站的 关于网站的设计和说明 还有SQL的程序 数据库
💻 CS
字号:
namespace ASPNET.StarterKit.Communities {

    using System;
    using System.Web.UI;
    using System.Web.UI.WebControls;



    //*********************************************************************
    //
    // DeleteContentPage Class
    //
    // Represents the Delete Content Page. Enables users to delete
    // content pages from a community.
    //
    //*********************************************************************

    public class DeleteContentPage : SkinnedCommunityControl {
    
        string _skinFileName = "ContentPages_DeleteContentPage.ascx";

        Label lblTitle;
        Button btnOk;
        Button btnCancel;


        //*********************************************************************
        //
        // DeleteContentPage Constructor
        //
        // Calls the base SkinnedCommunityControl constructor
        // and assigns the default page skin. Also checks whether
        // current user has permissions to delete.
        //
        //*********************************************************************
        
		public DeleteContentPage() : base() {
            // Check Security
            if (!objUserInfo.MayDelete)
                CommunityGlobals.ForceLogin();


            // Assign a default skin file name
            if (SkinFileName == null)
                SkinFileName = _skinFileName;
        }
        
        //*********************************************************************
        //
        // SkinType Property
        //
        // Specifies the skins directory where this page's skin file is located.
        //
        //*********************************************************************
        
        override protected string SkinType {
            get { return "ContentSkins"; }
        }


        //*********************************************************************
        //
        // ContentPageID Property
        //
        // Represents the Content Page ID of the resource being deleted.
        //
        //*********************************************************************

        int ContentPageID {
            get { return (int)ViewState["ContentPageID"]; }
            set { ViewState["ContentPageID"] = value; }
        }


        //*********************************************************************
        //
        // ReturnUrl Property
        //
        // Represents the page that the user is redirected back to.
        //
        //*********************************************************************
        
        public string ReturnUrl {
            get {return (string)ViewState["ReturnUrl"];}
            set {ViewState["ReturnUrl"] = value; }
        
        }
       
        
        //*********************************************************************
        //
        // InitializeSkin Method
        //
        // Retrieves all the controls from the page skin.
        //
        //*********************************************************************

        override protected void InitializeSkin(Control skin) {
                
            // Find Title Label
            lblTitle = (Label)GetControl(skin, "lblTitle");
            
            // Find OK Button
            btnOk = (Button)GetControl(skin, "btnOk");
    		btnOk.Click += new System.EventHandler(btnOk_Click);

            // Find Cancel Button
            btnCancel = (Button)GetControl(skin, "btnCancel");
    		btnCancel.Click += new System.EventHandler(btnCancel_Click);
        } 


        //*********************************************************************
        //
        // OnLoad Method
        //
        // Assigns values to the controls from the page skin.
        //
        //*********************************************************************

        override protected void OnLoad(EventArgs e) {
            if (!Page.IsPostBack) {
                // Get the contentPageID
                ContentPageID = Int32.Parse(Context.Request.QueryString["id"]);

                // Get the return URL
                ReturnUrl = Context.Request.QueryString["ReturnUrl"];
                
                // Get the ContentPage Info
                ContentPageInfo _contentPageInfo = ContentPageUtility.GetContentPageInfoFromDB(ContentPageID, objSectionInfo.ID);
                
                // Assign Title
                EnsureChildControls();
                lblTitle.Text = _contentPageInfo.Title;
            }
        
        }
        

 
        //*********************************************************************
        //
        // btnOk_Click Method
        //
        // This method is raised by clicking the OK button in the Delete 
        // Content Page Form. The method calls the ContentPageUtility
        // to actually delete the content.
        //
        //*********************************************************************
        
        void btnOk_Click(Object s, EventArgs e) {
            ContentPageUtility.DeleteContentPage(ContentPageID, objSectionInfo.ID);
            
            if (ReturnUrl != null)
                Context.Response.Redirect(CommunityGlobals.CalculatePath(ReturnUrl));     
            else
                Context.Response.Redirect(CommunityGlobals.CalculatePath("default.aspx"));
        }       
 
   
        //*********************************************************************
        //
        // btnCancel_Click Method
        //
        // This method is raised by clicking the Cancel button. It redirects
        // the user back to the page represented by the ReturnUrl property.
        //
        //*********************************************************************

        void btnCancel_Click(Object s, EventArgs e) {
            if (ReturnUrl != null)
                Context.Response.Redirect(CommunityGlobals.CalculatePath(ReturnUrl));     
            else
                Context.Response.Redirect( CommunityGlobals.CalculatePath(String.Format("{0}.aspx", ContentPageID)));
        
        }       
 
        


    }
}

⌨️ 快捷键说明

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