protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                //this connection instance is for showing data

                Dbconnection db     = new Dbconnection();
                bool         valid  = true;
                string       pageid = Request.QueryString["pageid"];
                Debug.WriteLine("PageID:" + pageid);
                if (String.IsNullOrEmpty(pageid))
                {
                    valid = false;
                }

                //We will attempt to get the record we need
                if (valid)
                {
                    HttpPage page_record = db.FindHttpPage(Int32.Parse(pageid));

                    pagetitle.Text   = page_record.GetPageTitle();
                    pagecontent.Text = page_record.GetPageContent();
                    pageauthor.Text  = page_record.GetPageAuthor();
                }
            }
        }
        public void ShowPageInfo(Dbconnection db)
        {
            bool   valid  = true;
            string pageid = Request.QueryString["pageid"];

            if (String.IsNullOrEmpty(pageid))
            {
                valid = false;
            }
            if (valid)
            {
                //finding  the page we requested by refering the function FindHttpPage in Dbconnection.cs and gets the records to display on html page
                HttpPage page_record = db.FindHttpPage(Int32.Parse(pageid));
                heading.InnerHtml     = page_record.GetPageTitle();
                pagecontent.InnerHtml = page_record.GetPageContent();
                author.InnerHtml      = "Author:" + " " + page_record.GetPageAuthor();
                Publishdate.InnerHtml = "Published on" + " " + page_record.GetPagePublish_Date();
            }
            else
            {
                valid = false;
            }
        }
        // Update page
        public void UpdatePage(int pageid, HttpPage new_HttpPage)
        {
            string query = "update pages set pagetitle='{0}', pagebody='{1}', author='{2}' where pageid={3}";

            query = String.Format(query, new_HttpPage.GetPageTitle(), new_HttpPage.GetPageContent(), new_HttpPage.GetPageAuthor(), pageid);
            MySqlConnection Connect = new MySqlConnection(ConnectionString);
            MySqlCommand    cmd     = new MySqlCommand(query, Connect);

            try
            {
                Connect.Open();
                cmd.ExecuteNonQuery();
                Debug.WriteLine("Executed query " + query);
            }
            catch (Exception ex)
            {
                Debug.WriteLine("Something went wrong in the Updatepage Method!");
                Debug.WriteLine(ex.ToString());
            }
            Connect.Close();
        }
        //Add  New Page to database
        public void AddPage(HttpPage new_HttpPage)
        {
            string query = "insert into pages (pagetitle, pagebody, author, Publish_Date) values ('{0}','{1}','{2}','{3}')";

            query = String.Format(query, new_HttpPage.GetPageTitle(), new_HttpPage.GetPageContent(), new_HttpPage.GetPageAuthor(), new_HttpPage.GetPagePublish_Date());
            MySqlConnection Connect = new MySqlConnection(ConnectionString);
            MySqlCommand    cmd     = new MySqlCommand(query, Connect);

            try
            {
                Connect.Open();
                cmd.ExecuteNonQuery();
            }
            catch (Exception ex)
            {
                Debug.WriteLine("Something went wrong in the Addpage Method!");
                Debug.WriteLine(ex.ToString());
            }

            Connect.Close();
        }