protected void btnPost_Click(object sender, EventArgs e) { var user = Page.User as CustomPrincipal; if (user != null) { var subject = txtSubject.Text.Replace("Re:", "").Trim(); var disc = new Academic.DbEntities.ActivityAndResource.ForumItems.ForumDiscussion() { Id = DiscussionId , ForumActivityId = ForumId , Subject = subject , Message = txtMessage.Text , PostedById = user.Id , PostedDate = DateTime.Now //,Closed = , LastPostById = user.Id , LastPostDate = DateTime.Now , Pinned = chkPinned.Checked , SubscribeToDiscussion = chkSubscribeToDiscussion.Checked }; if (ParentDiscussionId > 0) { disc.ParentDiscussionId = ParentDiscussionId; } using (var helper = new DbHelper.ActAndRes()) { var saved = helper.AddOrUpdateDiscussion(user.Id, disc); if (saved != null) { if ((ParentDiscussionId > 0 || DiscussionId > 0) && MainDiscussionId > 0)// then this is child discussion of ParentDiscussionId { Response.Redirect("~/Views/ActivityResource/Forum/DiscussionView.aspx?fId=" + ForumId + "&disId=" + MainDiscussionId + "&SubId=" + SubjectId + "&fId=" + ForumId + "&secId=" + SectionId + "#section_" + saved.Id); } else// this is parent discussion {//SubId=19&arId=2&secId=2&edit=0 Response.Redirect("~/Views/ActivityResource/Forum/ForumView.aspx?SubId=" + SubjectId + "&arId=" + ForumId + "&secId=" + SectionId + "#section_" + saved.Id); } Response.Redirect(""); } } } }