示例#1
0
        // 提交评论
        protected void SubmitCmnt_Click(object sender, EventArgs e)
        {
            string cmntContent = CmntContent.Text;

            if (cmntContent == "")
            {
                CmntContent.Attributes["placeholder"] = "输入内容不能为空!";

                return;
            }

            Comment cmnt = new Comment();

            cmnt.ArticleId = GetId();
            cmnt.Username  = Session["Username"].ToString();
            cmnt.Content   = cmntContent;
            cmnt.CmntTime  = DateTime.Now.ToLocalTime();

            bool isOk = CommentService.AddCmnt(cmnt);

            if (isOk)
            {
                SetArticleToPage(GetId());

                Response.Redirect(Request.Url.ToString()); // 刷新本页
            }
        }