Example #1
0
    //回复帖子
    protected void ImageButton1_Click(object sender, ImageClickEventArgs e)
    {
        //若用户没有登陆 跳转到错误页面
        if (Session["usernick"] == null)
        {
            Response.Redirect("ErrorMsg.aspx");
            return;
        }

        //添加留言

        localhost.Service myBBS = new localhost.Service();

        //通过选择不同的分区来获得分区的id,并且通过当前的用户名、昵称名来更新数据库中的信息
        int state = myBBS.AppearRes(Convert.ToInt32(Request.QueryString.GetValues(0)[0]), ContentTbx.Text.ToString(), Session["usernick"].ToString(), Session["username"].ToString());

        if (state == 1)
        {
            //显示留言成功 并重新显示用户回复
            lblMsg.Text = "留言成功";

            localhost.Service bbsDb = new localhost.Service();
            //获取更新后的回复内容
            DataSet ContentDS = bbsDb.GetContent(Convert.ToInt32(Request.QueryString.GetValues(0)[0]));
            DataList2.DataSource = ContentDS.Tables["NoteContent"].DefaultView;
            DataList2.DataBind();
        }
        else
        {
            lblMsg.Text = "留言失败";
        }
        return;
    }