Пример #1
0
        } // END ShowPageInfo

        protected void Update_Page(object sender, EventArgs e)
        {
            PAGESDB pages_db = new PAGESDB();

            bool   valid  = true;
            string pageid = Request.QueryString["page_id"];

            if (String.IsNullOrEmpty(pageid))
            {
                valid = false;
            }
            if (valid)
            {
                HTTP_Page new_page = new HTTP_Page();
                new_page.Set_http_title(page_title.Text);
                new_page.Set_http_body(page_body.Text);
                new_page.Set_http_publish(page_publish.Checked);

                try
                {
                    pages_db.UpdatePage(Int32.Parse(pageid), new_page);
                    Response.Redirect("ShowPage.aspx?page_id=" + pageid);
                } // END TRY
                catch
                {
                    valid = false;
                } // END CATCH
            }
            if (!valid)
            {
                edit_page.InnerHtml = "There was an error updating that page.";
            }

            ShowPageInfo(pages_db);
        } // END Update_Page
Пример #2
0
        } // END Page_Load

        protected void ShowPageInfo(PAGESDB pages_db)
        {
            bool   valid  = true;
            string pageid = Request.QueryString["page_id"];

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

            // ATTEMPT TO GET PAGE RECORD:
            if (valid)
            {
                Dictionary <String, String> page_record = pages_db.FindPage(Int32.Parse(pageid));

                if (page_record.Count > 0)
                {
                    page_title.Text = page_record["page_title"];
                    page_body.Text  = page_record["page_body"];
                }
                else
                {
                    valid = false;
                }
            }

            if (!valid)
            {
                edit_page.InnerHtml = "There was an error finding that page.";
            }
        } // END ShowPageInfo
Пример #3
0
        protected void Page_Load(object sender, EventArgs e)
        {
            PAGESDB pages_db = new PAGESDB();

            if (!Page.IsPostBack)
            {
                // POPULATE FIELDS:
                ShowPageInfo(pages_db);
            }
        } // END Page_Load
        protected void Page_Load(object sender, EventArgs e)
        {
            var pages_db = new PAGESDB();

            ShowPageDetails(pages_db);

            // ASP BUTTON REDIRECT
            // SRC: https://stackoverflow.com/questions/23976683/asp-net-button-to-redirect-to-another-page

            edit_button.PostBackUrl = "~/EditPage.aspx?page_id=" + Request.QueryString["page_id"];
        } // END Page_Load
        protected void Add_Page(object sender, EventArgs e)
        {
            PAGESDB pages_db = new PAGESDB();

            HTTP_Page new_page = new HTTP_Page();

            new_page.Set_http_title(page_title.Text);
            new_page.Set_http_body(page_body.Text);
            new_page.Set_http_publish(page_publish.Checked);

            pages_db.AddPage(new_page);

            Response.Redirect("ListPages.aspx");
        } // END Add_Page
        protected void Page_Load(object sender, EventArgs e)
        {
            nav_menu.InnerHtml = "";

            string query = "select * from pages";

            nav_menu.InnerHtml += "<ul class=\"nav navbar-nav\">";

            // DISPLAY CONTENT IN MENU:
            var pages_db = new PAGESDB();
            List <Dictionary <String, String> > results = pages_db.List_Query(query);

            foreach (Dictionary <String, String> row in results)
            {
                nav_menu.InnerHtml += "<li><a href=\"ShowPage.aspx?page_id=" + row["page_id"] + "\">" + row["page_title"] + "</a></li>";
            }

            nav_menu.InnerHtml += "</ul>";
        }
        } // END ShowPageDetails

        // Delete_Page FUNCTION
        // SRC: CRUD Essentials - Christine Bittle
        protected void Delete_Page(object sender, EventArgs e)
        {
            bool   valid  = true;
            string pageid = Request.QueryString["page_id"];

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

            PAGESDB pages_db = new PAGESDB();

            // DELETE PAGE FROM DB:
            if (valid)
            {
                pages_db.DeletePage(Int32.Parse(pageid));
                Response.Redirect("ListPages.aspx");
            }
        } // END Delete_Page
        } // END Page_Load

        protected void ShowPageDetails(PAGESDB pages_db)
        {
            bool   valid  = true;
            string pageid = Request.QueryString["page_id"];

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

            if (valid)
            {
                Dictionary <String, String> page_record = pages_db.FindPage(Int32.Parse(pageid));

                if (page_record.Count > 0)
                {
                    title.InnerHtml        = "for " + page_record["page_title"];
                    page_title.InnerHtml   = page_record["page_title"];
                    body_content.InnerHtml = page_record["page_body"];


                    page_published.InnerHtml = (page_record["page_published"] == "True") ? "Yes" : "No";
                    // SRC: https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/operators/conditional-operator
                    // Ternary conditional operator

                    string   page_created          = page_record["date_created"];
                    DateTime date_created_datetime = Convert.ToDateTime(page_created);
                    DateTime date_created_dateonly = date_created_datetime.Date;
                    date_created.InnerHtml = date_created_dateonly.ToString("d");
                    // SRC: HOW TO REMOVE TIME STAMP
                    // https://docs.microsoft.com/en-us/dotnet/api/system.datetime.date?redirectedfrom=MSDN&view=netframework-4.8#System_DateTime_Date
                }
                else
                {
                    valid = false;
                }
            }

            if (!valid)
            {
                page_details.InnerHtml = "There was an error finding that page.";
            }
        } // END ShowPageDetails
Пример #9
0
        protected void Page_Load(object sender, EventArgs e)
        {
            pages_result.InnerHtml = "";

            string searchkey = "";



            if (Page.IsPostBack)
            {
                searchkey = page_search.Text;
            }

            string query = "select * from pages";

            if (searchkey != "")
            {
                query += " WHERE LOWER(page_title) LIKE '%" + searchkey + "%'";
                query += " OR LOWER(page_body) LIKE '%" + searchkey + "%'";
                query += " OR date_created LIKE '%" + searchkey + "%'";
            }

            // DISPLAY CONTENT IN TABLE:
            var pages_db = new PAGESDB();
            List <Dictionary <String, String> > results = pages_db.List_Query(query);

            foreach (Dictionary <String, String> row in results)
            {
                TableRow table_row = new TableRow();

                TableCell table_cell = new TableCell
                {
                    Text = "<a href=\"ShowPage.aspx?page_id=" + row["page_id"] + "\">" + row["page_title"] + "</a>"
                };
                table_row.Cells.Add(table_cell);

                TableCell table_cell2 = new TableCell
                {
                    Text = row["page_body"]
                };
                table_row.Cells.Add(table_cell2);

                string page_pub = "";

                if (row["page_published"] == "True")
                {
                    page_pub = "Yes";
                }
                else
                {
                    page_pub = "No";
                }


                TableCell table_cell3 = new TableCell
                {
                    Text = page_pub
                };
                table_row.Cells.Add(table_cell3);

                // REMOVE TIMESTAMP IN date_created:
                string   date_created          = row["date_created"];
                DateTime date_created_datetime = Convert.ToDateTime(date_created);
                DateTime date_created_dateonly = date_created_datetime.Date;
                // SRC: HOW TO REMOVE TIME STAMP
                // https://docs.microsoft.com/en-us/dotnet/api/system.datetime.date?redirectedfrom=MSDN&view=netframework-4.8#System_DateTime_Date


                TableCell table_cell4 = new TableCell
                {
                    Text = date_created_dateonly.ToString("d")
                };
                table_row.Cells.Add(table_cell4);

                // ADD ROW TO TABLE:
                list_pages_table.Rows.Add(table_row);
            } // END OF FOREACH LOOP
        }