protected void Page_Load(object sender, EventArgs e) { if (Session["Admin"] == null) { Response.Redirect("Admin.aspx"); } if (Request.QueryString["src"] == null) { lbTitle.Visible = false; } else { txtTitle.Visible = false; if (!IsPostBack) { Entity.Article article = new Entity.Article(); if (Request.QueryString["IsPage"] != null) { article.IsPage = true; } article.Title = Request.QueryString["src"]; txtContent.Text = article.MarkdownContent; } } }
protected void BtnSubmit_Click(object sender, EventArgs e) { if (Request.QueryString["src"] == null) { bool IsExisted; if (Request.QueryString["IsPage"] == null) { IsExisted = (from a in Dal.ArticleDao.Articles where a.Title == txtTitle.Text select a.Title).Count() == 0 ? false : true; } else { IsExisted = (from a in Dal.ArticleDao.Pages where a.Title == txtTitle.Text select a.Title).Count() == 0 ? false : true; } if (IsExisted) { lbInfo.Text = "文章/页面标题已存在,请修改后尝试!"; } else if (txtTitle.Text.Trim(' ') == "") { lbInfo.Text = "文章/页面标题不可为空!"; } else { Entity.Article article = new Entity.Article(); if (Request.QueryString["IsPage"] != null) article.IsPage = true; article.Title = txtTitle.Text; article.MarkdownContent = txtContent.Text; Dal.ArticleDao.Push(article); if (Request.QueryString["IsPage"] == null) Response.Redirect("Admin_Articles.aspx"); else Response.Redirect("Admin_Pages.aspx"); } } else { Entity.Article article = new Entity.Article(); if (Request.QueryString["IsPage"] != null) article.IsPage = true; article.Title = Request.QueryString["src"]; article.MarkdownContent = txtContent.Text; article.Save(); Dal.ArticleDao.Rebuild(); if (Request.QueryString["IsPage"] == null) Response.Redirect("Admin_Articles.aspx"); else Response.Redirect("Admin_Pages.aspx"); } }
protected void BtnSubmit_Click(object sender, EventArgs e) { if (Request.QueryString["src"] == null) { bool IsExisted; if (Request.QueryString["IsPage"] == null) { IsExisted = (from a in Dal.ArticleDao.Articles where a.Title == txtTitle.Text select a.Title).Count() == 0 ? false : true; } else { IsExisted = (from a in Dal.ArticleDao.Pages where a.Title == txtTitle.Text select a.Title).Count() == 0 ? false : true; } if (IsExisted) { lbInfo.Text = "文章/页面标题已存在,请修改后尝试!"; } else if (txtTitle.Text.Trim(' ') == "") { lbInfo.Text = "文章/页面标题不可为空!"; } else { Entity.Article article = new Entity.Article(); if (Request.QueryString["IsPage"] != null) { article.IsPage = true; } article.Title = txtTitle.Text; article.MarkdownContent = txtContent.Text; Dal.ArticleDao.Push(article); if (Request.QueryString["IsPage"] == null) { Response.Redirect("Admin_Articles.aspx"); } else { Response.Redirect("Admin_Pages.aspx"); } } } else { Entity.Article article = new Entity.Article(); if (Request.QueryString["IsPage"] != null) { article.IsPage = true; } article.Title = Request.QueryString["src"]; article.MarkdownContent = txtContent.Text; article.Save(); Dal.ArticleDao.Rebuild(); if (Request.QueryString["IsPage"] == null) { Response.Redirect("Admin_Articles.aspx"); } else { Response.Redirect("Admin_Pages.aspx"); } } }
protected void Page_Load(object sender, EventArgs e) { if (Session["Admin"] == null) Response.Redirect("Admin.aspx"); if (Request.QueryString["src"] == null) { lbTitle.Visible = false; } else { txtTitle.Visible = false; if (!IsPostBack) { Entity.Article article = new Entity.Article(); if (Request.QueryString["IsPage"] != null) article.IsPage = true; article.Title = Request.QueryString["src"]; txtContent.Text = article.MarkdownContent; } } }