protected void ShowContentPageDetail()
        {
            bool   valid          = true;
            string ContentPage_Id = Request.QueryString["id"];

            if (String.IsNullOrEmpty(ContentPage_Id))
            {
                valid = false;
            }

            //We will attempt to get the record we need
            if (valid)
            {
                CMSDB       db = new CMSDB();
                ContentPage ContentPage_Record = db.GetContentPageById(Int32.Parse(ContentPage_Id));
                contentpage_title.InnerHtml       = ContentPage_Record.Title;
                contentpage_body.Text             = ContentPage_Record.Body;
                contentpage_publishdate.InnerText = ContentPage_Record.PublishDate.ToString("D");
            }
            else
            {
                valid = false;
            }

            if (!valid)
            {
                contentpage_body_panel.InnerHtml = "There was an error finding that Content Page.";
            }
        }
示例#2
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!Page.IsPostBack)
     {
         CMSDB db = new CMSDB();
         //Connection to db and fetch all content pages
         ListNavigationContentPages(db);
     }
 }
        protected void search_btn_Click(object sender, EventArgs e)
        {
            //Create connection to database
            CMSDB db = new CMSDB();

            //store the search keyword in variable
            string Search_Keywords = search_keyword.Text.Trim();

            //Bind Gridview after searching
            contentpages_list_gridview.DataSource = db.SearchContentPagesByPageTitle(Search_Keywords);
            contentpages_list_gridview.DataBind();
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                //Create connection to database
                CMSDB db = new CMSDB();

                //Bind Gridview with data
                contentpages_list_gridview.DataSource = db.ListContentPages();
                contentpages_list_gridview.DataBind();
            }
        }
示例#5
0
        private void ListNavigationContentPages(CMSDB db)
        {
            List <ContentPage> ContentPage_List = new List <ContentPage>();

            ContentPage_List = db.GetNavigationMenuData();

            foreach (ContentPage page in ContentPage_List)
            {
                //Set the Main navigation to all content pages page title
                string url = "<li><a href='ViewContentPage.aspx?id={0}'>{1}</a></li>";
                url = string.Format(url, page.Id, page.Title);
                header_nav.InnerHtml += url;
            }
        }
        protected void delete_contentpage_Click(object sender, EventArgs e)
        {
            bool   valid          = true;
            string ContentPage_Id = Request.QueryString["id"];

            if (String.IsNullOrEmpty(ContentPage_Id))
            {
                valid = false;
            }

            //We will attempt to get the record we need
            if (valid)
            {
                CMSDB db = new CMSDB();
                db.DeleteContentPage(Int32.Parse(ContentPage_Id));
                Response.Redirect("ListContentPages.aspx");
            }
        }
示例#7
0
        protected void btn_submit_Click(object sender, EventArgs e)
        {
            //create connection to cms database
            CMSDB db = new CMSDB();

            //create a new content page
            ContentPage ContentPage = new ContentPage();

            //set content page data
            ContentPage.Title       = contentpage_title.Text.Trim();
            ContentPage.Body        = contentpage_body.Text.Trim();
            ContentPage.PublishDate = DateTime.Now;

            //add the content page to the database
            db.AddContentPage(ContentPage);

            Response.Redirect("ListContentPages.aspx");
        }
        protected void btn_submit_Click(object sender, EventArgs e)
        {
            bool   valid          = true;
            string ContentPage_Id = Request.QueryString["id"];

            if (String.IsNullOrEmpty(ContentPage_Id))
            {
                valid = false;
            }

            //We will attempt to update the record we need
            if (valid)
            {
                //create connection to cms database
                CMSDB db = new CMSDB();

                //create a new content page
                ContentPage ContentPage = new ContentPage();

                //set that content page data
                ContentPage.Title       = contentpage_title.Text.Trim();
                ContentPage.Body        = contentpage_body.Text.Trim();
                ContentPage.PublishDate = DateTime.Now;

                //update the content page to the database
                db.UpdateContentPage(Convert.ToInt32(ContentPage_Id), ContentPage);

                Response.Redirect("ListContentPages.aspx");
            }
            else
            {
                valid = false;
            }

            if (!valid)
            {
                contentpage_body_panel.InnerHtml = "There was an error finding that Content Page.";
            }
        }
        protected void contentpages_list_gridview_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            //Redirect to content page detail
            if (e.CommandName == "view_contentpage")
            {
                Response.Redirect("ViewContentPage.aspx?id=" + e.CommandArgument.ToString());
            }
            //Redirect to content page editing
            else if (e.CommandName == "edit_contentpage")
            {
                Response.Redirect("EditContentPage.aspx?id=" + e.CommandArgument.ToString());
            }
            else if (e.CommandName == "publish_unpublish_contentpage")
            {
                string[] commandArgs  = e.CommandArgument.ToString().Split(new char[] { ',' });
                int      Content_Id   = Convert.ToInt32(commandArgs[0]);
                bool     Is_Published = Convert.ToBoolean(commandArgs[1]);

                //Change the opposite status
                CMSDB db = new CMSDB();
                db.PublishUnpublishContentPage(Content_Id, !Is_Published);
                Response.Redirect("ListContentPages.aspx");
            }
        }