private void Page_Load(object sender, System.EventArgs e) { int threadID = HnDGeneralUtils.TryConvertToInt(Request.QueryString["ThreadID"]); _deleteMessageID = HnDGeneralUtils.TryConvertToInt(Request.QueryString["MessageID"]); _thread = ThreadGuiHelper.GetThread(threadID); if (_thread == null) { // not found, return to default page Response.Redirect("default.aspx", true); } // Check if the current user is allowed to delete the message. If not, don't continue. _userMayDeleteMessages = SessionAdapter.CanPerformForumActionRight(_thread.ForumID, ActionRights.EditDeleteOtherUsersMessages); if (!_userMayDeleteMessages) { // is not allowed to delete the message Response.Redirect("Messages.aspx?ThreadID=" + threadID, true); } // check if the user can view this thread. If not, don't continue. if ((_thread.StartedByUserID != SessionAdapter.GetUserID()) && !SessionAdapter.CanPerformForumActionRight(_thread.ForumID, ActionRights.ViewNormalThreadsStartedByOthers) && !_thread.IsSticky) { // can't view this thread, it isn't visible to the user Response.Redirect("default.aspx", true); } // check if the message is the first message in the thread. If so, delete isn't allowed. if (ThreadGuiHelper.CheckIfMessageIsFirstInThread(threadID, _deleteMessageID)) { // is first in thread, don't proceed. Caller has fabricated the url manually. Response.Redirect("default.aspx", true); } // Get the message MessageEntity message = MessageGuiHelper.GetMessage(_deleteMessageID); // User may delete current message. if (!Page.IsPostBack) { if (message != null) { // message is found. ForumEntity forum = CacheManager.GetForum(_thread.ForumID); if (forum == null) { // Orphaned thread Response.Redirect("default.aspx", true); } lblForumName_Header.Text = forum.ForumName; lblMessageBody.Text = message.MessageTextAsHTML; lblPostingDate.Text = message.PostingDate.ToString(@"dd-MMM-yyyy HH:mm:ss"); } else { btnYes.Visible = false; } } }