private void SendComment() { string strNewsCode = Request.Form["NewsCode"]; string Name = Request.Form["Name"]; string Email = Request.Form["Email"]; string Comment = Request.Form["Comment"]; int HCSectionCode = 1; int ItemCode; Int32.TryParse(strNewsCode, out ItemCode); BOLComments CommentsBOL = new BOLComments(); bool Result = CommentsBOL.SaveComment(HCSectionCode, ItemCode, Name, Email, Comment); op_result _op_result = new op_result(); if (Result) { _op_result.result = "نظر با موفقیت ثبت شد"; //msgBox.Text = "نظر شما با موفقیت دریافت شد"; } else { _op_result.result = "متاسفانه خطایی در ثبت نظر رخ داده است"; } JavaScriptSerializer serializer = new JavaScriptSerializer(); string json = serializer.Serialize((object)_op_result); Response.Write(json); Response.End(); }
protected void btnSendComment_Click(object sender, EventArgs e) { if (!RadCaptcha1.IsValid) { msgBox.MessageTextMode = AKP.Web.Controls.Common.MessageMode.Error; msgBox.Text = "کد امنیتی اشتباه است"; return; } msgBox.Text = ""; string Name = txtName.Text.Trim(); string Email = txtEmail.Text.Trim(); string Comment = txtComment.Text.Trim(); if (Comment == "") { msgBox.MessageTextMode = AKP.Web.Controls.Common.MessageMode.Error; msgBox.Text = "لطفا پیام را وارد کنید"; return; } if (ViewState["ItemCode"] != null && ViewState["HCSectionCode"] != null) { int HCSectionCode = Convert.ToInt32(ViewState["HCSectionCode"]); int ItemCode = Convert.ToInt32(ViewState["ItemCode"]); BOLComments CommentsBOL = new BOLComments(); bool Result = CommentsBOL.SaveComment(HCSectionCode, ItemCode, Name, Email, Comment); if (Result) { msgBox.MessageTextMode = AKP.Web.Controls.Common.MessageMode.OK; msgBox.Text = "نظر شما با موفقیت دریافت شد"; btnSendComment.Visible = false; } else { msgBox.MessageTextMode = AKP.Web.Controls.Common.MessageMode.Error; msgBox.Text = "متاسفانه خطایی در ثبت نظر رخ داده است"; } } }