protected void btnAddComment_Click(object sender, EventArgs e) { if (string.IsNullOrEmpty(tbComment.Text)) { lbResult.Text = "コメントを入力して下さい"; return; } DataDoc dc = DataDoc.Instance(Server); lock (dc) { HttpCookie hc = Request.Cookies["user"]; string user; if (hc == null || string.IsNullOrEmpty(user = MasterPage.UserName(hc))) { lbResult.Text = "ログインして下さい"; return; } Answer aw = dc.GetAnswer((int?)Session["Answer"]); if (aw == null) { lbResult.Text = "対象がありません"; return; } dc.AddComment(aw.ID, user, tbComment.Text); dc.Save(null); } SetData(); }