private void BtnSaveClick(object sender, EventArgs e)
{
if (!this.Page.IsValid)
{
throw new InvalidOperationException("One or more validators are invalid.");
}
var page = this.Request.QueryString["id"] != null ? BlogEngine.Core.Page.GetPage(new Guid(this.Request.QueryString["id"])) : new BlogEngine.Core.Page();
if (string.IsNullOrEmpty(this.txtContent.Text))
{
this.txtContent.Text = "[No text]";
}
page.Title = this.txtTitle.Text;
page.Content = this.txtContent.Text;
page.Description = this.txtDescription.Text;
page.Keywords = this.txtKeyword.Text;
if (this.cbFrontPage.Checked)
{
foreach (var otherPage in BlogEngine.Core.Page.Pages.Where(otherPage => otherPage.IsFrontPage))
{
otherPage.IsFrontPage = false;
otherPage.Save();
}
}
page.IsFrontPage = this.cbFrontPage.Checked;
page.ShowInList = this.cbShowInList.Checked;
page.IsPublished = this.cbPublished.Checked;
if (!string.IsNullOrEmpty(this.txtSlug.Text))
{
page.Slug = Utils.RemoveIllegalCharacters(this.txtSlug.Text.Trim());
}
page.Parent = this.ddlParent.SelectedIndex != 0 ? new Guid(this.ddlParent.SelectedValue) : Guid.Empty;
page.Save();
this.Response.Redirect(page.RelativeLink);
}