/// <summary> /// 提交按钮 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void Button1_Click(object sender, EventArgs e) { string userName = ""; string userRole = ""; if (txtTitle.Text == "") { Page.ClientScript.RegisterStartupScript(this.GetType(), "异常", "<script>alert('帖子标题不能为空!')</script>"); return; } userName = Session["Name"].ToString(); userRole = Session["Role"].ToString(); post.PostTitle = txtTitle.Text.Trim(); post.UserID = int.Parse(Session["userId"].ToString().Trim()); post.PostContent = FreeTextBox1.Text; post.PostDate = DateTime.Now; post.ModuleID = Convert.ToInt32(ddList.SelectedValue); if (postBll.CreatePost(post)) { Response.Redirect("postList.aspx?ModuleID=" + post.ModuleID); } else { Session["errorMsg"] = "请检查你的权限"; Response.Redirect("errorPage.aspx"); } }