protected void MyAnonymousComment_Button_Click(object sender, EventArgs e) { if (Session["UserInfo"] != null) { if (MyComment_TextBox.Text.Trim() == "" || MyComment_TextBox.Text == "你还没有对此课程发表任何评论哦") { ScriptManager.RegisterStartupScript(Page, GetType(), "nocontent", "alert('请输入内容!');", true); //HttpContext.Current.Response.Write("<script type='text/javascript'>alert('请输入内容!');location.href='/aspx/Course.aspx?CourseID=" + courseid + "'</script>"); } else { Byte[] tags = new Byte[20]; Byte a = 1, b = 0;; for (int i = 1; i <= 6; i++) { tags[i - 1] = ((CheckBox)FindControl("MyCommentTag" + i.ToString() + "_CheckBox")).Checked == true ? a : b; } MessageInfo mycomment = new MessageInfo(); mycomment.Anonymous = 1; mycomment.UserID = user.UserID; mycomment.CourseID = course.CourseID; mycomment.Content = MyComment_TextBox.Text; mycomment.Tags = tags; switch (mycomment.AddComment()) { case 1: AllDataBind(); break; case -1: AllDataBind(); ScriptManager.RegisterStartupScript(Page, GetType(), "havecomment", "alert('评论已存在');", true); break; default: ScriptManager.RegisterStartupScript(Page, GetType(), "commentfailed", "alert('评论失败');", true); break; } } } else { HttpContext.Current.Response.Write("<script type='text/javascript'>alert('闲置时间过长,请重新登录');location.href='" + Request.Url.AbsoluteUri + "'</script>"); } }