protected void dgvCustomPages_RowCommand(object sender, GridViewCommandEventArgs e) { if (e.CommandName == "deleteCustomPage") { CustomPage customPage = new CustomPageBL().GetCustomPage(int.Parse(e.CommandArgument.ToString())); new CustomPageBL().Delete(customPage); Common.RemoveUrlRewrite(customPage.Url); loadCustomPages(); } }
private void loadCustomPage(string url) { CustomPageBL customPageBL = new CustomPageBL(); CustomPage customPage = customPageBL.GetCustomPage(url); if (customPage != null) { Page.Title = customPage.Title; ViewState.Add("pageTitle", customPage.Title); lblHeading.Text = customPage.Heading; divContent.InnerHtml = customPage.Content; lblHeader.Text = customPage.Head; lblFooter.Text = customPage.Footer; } else Server.Transfer("~/errors/not-found.html"); }
private void loadCustomPage(int customPageID) { CustomPageBL customPageBL = new CustomPageBL(); CustomPage customPage = customPageBL.GetCustomPage(customPageID); txtTitle.Text = customPage.Title; txtDescription.Text = customPage.Description; txtUrl.Text = customPage.Url; txtHeading.Text = customPage.Heading; txtHead.Text = customPage.Head; txtInsertDate.Text = customPage._insertDate.ToString(); txtUpdateDate.Text = customPage._updateDate.ToString(); txtContent.Text = customPage.Content; ViewState.Add("customPageID", customPage.ID); lblTitleHeading.Text = customPage.Heading; ViewState.Add("pageTitle", customPage.Title); chkIsActive.Checked = customPage._isActive; cmbCustomPageCategory.SelectedValue = customPage.CustomPageCategory.ID.ToString(); txtFooter.Text = customPage.Footer; }
private void save() { try { CustomPage customPage = new CustomPage(); customPage.ID = (ViewState["customPageID"] != null) ? int.Parse(ViewState["customPageID"].ToString()) : 0; int customPageID = customPage.ID; customPage.Title = txtTitle.Text; customPage.Description = txtDescription.Text; customPage.Url = txtUrl.Text; customPage.Heading = txtHeading.Text; customPage.Head = txtHead.Text; customPage._insertDate = DateTime.Now.ToUniversalTime(); customPage._updateDate = DateTime.Now.ToUniversalTime(); customPage.Content = txtContent.Text; customPage.SortIndex = 1; customPage.ImageUrl = string.Empty; customPage._isActive = chkIsActive.Checked; customPage.CustomPageCategory = new CustomPageCategory(string.Empty, int.Parse(cmbCustomPageCategory.SelectedValue)); customPage.Footer = txtFooter.Text; CustomPageBL customPageBL = new CustomPageBL(); customPage.ID = customPageBL.Save(customPage); if (customPageID == 0) Common.AddUrlRewrite(customPage.Url, "customPage.aspx"); lblTitleHeading.Text = customPage.Heading; ViewState.Add("customPageID", customPage.ID); ViewState.Add("pageTitle", customPage.Title); divAlert.Visible = true; divAlert.Attributes["class"] = "alert alert-success text-center"; lblAlert.Text = "Custom page saved"; } catch (Exception ex) { divAlert.Visible = true; divAlert.Attributes["class"] = "alert alert-danger text-center"; lblAlert.Text = ex.Message; } }