protected void ResultsRowDataBound(object sender, GridViewRowEventArgs e) { if (e.Row.RowType == DataControlRowType.DataRow) { var topic = (TopicInfo)e.Row.DataItem; var popuplink = e.Row.Cells[4].FindControl("popuplink") as Literal; if (popuplink != null) { string title = String.Format(webResources.lblViewProfile, "$1"); popuplink.Text = topic.LastPostAuthorId != null?Regex.Replace(topic.LastPostAuthorPopup, @"\[!(.*)!]", title) : ""; } int replyCount = topic.ReplyCount; e.Row.Cells[0].Controls.Add(GetRecentTopicIcon((Enumerators.PostStatus)topic.Status, replyCount)); //if (HttpContext.Current.User.Identity.Name == "") //{ // if (e.Row.Cells.Count > 2) // { // e.Row.Cells.RemoveAt(4); // } //} } else if (e.Row.RowType == DataControlRowType.Pager) { var ph = (PlaceHolder)e.Row.FindControl("phPager"); _replyPager.PageCount = Common.CalculateNumberOfPages(RowCount, Convert.ToInt32(ddlPageSize.SelectedValue)); PopulateObject populate = PopulateData; _replyPager.UpdateIndex = populate; ph.Controls.Add(_replyPager); } }
private void BindMembers() { pager.Controls.Clear(); RowCount = Members.GetMemberCount(); _memberPager = (GridPager)LoadControl("~/UserControls/GridPager.ascx"); _memberPager.ID = "memPager"; _memberPager.PagerStyle = Enumerators.PagerType.Linkbutton; _memberPager.UserControlLinkClick += PagerLinkClick; _memberPager.PageCount = Common.CalculateNumberOfPages(RowCount, Config.MemberPageSize); _memberPager.CurrentIndex = CurrentPage; MGV.PageSize = Config.MemberPageSize; PopulateObject populate = PopulateData; _memberPager.UpdateIndex = populate; pager.Controls.Add(_memberPager); }
protected override void OnInit(EventArgs e) { base.OnInit(e); this.PageScriptManager.Services.Add(new ServiceReference("~/CommonFunc.asmx")); if (Session["CurrentProfile"] != null) { Session.Remove("CurrentProfile"); } editorCSS.Attributes.Add("href", "/css/" + Page.Theme + "/editor.css"); jsshareCSS.Attributes.Add("href", "/css/" + Page.Theme + "/jsShare.css"); if (TopicId == null) { throw new HttpException(404, "Topic not found"); } if (Request.QueryString["ARCHIVE"] != null) { if (Request.QueryString["ARCHIVE"] == "1") { ArchiveView = 1; } } else { ArchiveView = 0; } try { if (TopicId != null) { if (Session["TOPIC"] == null) { Session.Add("TOPIC", TopicId); } else { Session["TOPIC"] = TopicId; } string skip = ""; if (!String.IsNullOrEmpty(Request.Params["dir"])) { skip = Request.Params["dir"]; } _topic = Topics.GetTopic(TopicId.Value); _forum = Forums.GetForum(_topic.ForumId); if (_forum.Type == (int)Enumerators.ForumType.BlogPosts) { MinWeblog.MemberId = _topic.AuthorId; MinWeblog.ForumId = _topic.ForumId; MinWeblog.Visible = true; } else { MinWeblog.Visible = false; } if (skip != "") { _topic = Topics.GetNextPrevTopic(_topic.Id, skip); TopicId = _topic.Id; } _topic.Author = Members.GetAuthor(_topic.AuthorId); //Grid pager setup ReplyPager = (GridPager)LoadControl("~/UserControls/GridPager.ascx"); ReplyPager.PagerStyle = Enumerators.PagerType.Linkbutton; ReplyPager.UserControlLinkClick += PagerLinkClick; RowCount = _topic.ReplyCount; ReplyPager.PageCount = Common.CalculateNumberOfPages(RowCount, Config.TopicPageSize); Page.Title = string.Format(webResources.ttlTopicPage, _topic.Subject.CleanForumCodeTags(), Config.ForumTitle); string pagedescription = _topic.Message.CleanForumCodeTags(); metadescription.Text = String.Format("<meta name=\"description\" content=\"{0}\">", HttpUtility.HtmlEncode(pagedescription.Substring(0, Math.Min(160, pagedescription.Length)))); } } catch (Exception) { throw new HttpException(404, "Topic not found"); } var meta = new HtmlMeta(); meta.Attributes.Add("name", "description"); meta.Attributes.Add("content", _topic.Subject); Page.Header.Controls.Add(meta); if (User.Identity.IsAuthenticated) { if ((Config.ShowQuickReply && _topic.Status != (int)Enumerators.PostStatus.Closed && _topic.Forum.Status != (int)Enumerators.PostStatus.Closed) || IsAdministrator) { var qr = (QuickReply)Page.LoadControl("~/UserControls/QuickReply.ascx"); //loading the user control dynamically qr.thisTopic = _topic; QRPlaceHolder.Controls.Add(qr); } } PopulateObject populate = PopulateData; ReplyPager.UpdateIndex = populate; pager.Controls.Add(ReplyPager); }
protected void Page_Load(object sender, EventArgs e) { if (CurrentPage == -1) { CurrentPage = 0; } if (ForumId != null) { _currentForum = Forums.GetForum(ForumId.Value); if (_currentForum == null) { throw new ArgumentException("Invalid Forum ID"); } if (_currentForum.Type == 1) { Response.Redirect(_currentForum.Url, true); } fLogin.forum = _currentForum; if (!IsPostBack) { if (IsAuthenticated) { //do we have access to this forum if (!Forums.IsUserInForumRole(Member.Username, ForumId.Value)) { if (Session[session] == null || Session[session].ToString() != ForumId.ToString()) { if (_currentForum.Password != null && !String.IsNullOrEmpty(_currentForum.Password.Trim())) { if (Session[session] == null || Session[session].ToString() == "") { var mp = (ModalPopupExtender)fLogin.FindControl("popup"); var masterPage = this.Page.Master; if (masterPage != null) { var cph = (ContentPlaceHolder)masterPage.FindControl("CPM"); cph.Visible = false; } mp.Show(); } else { if (Session[session].ToString() != ForumId.ToString()) { throw new SecurityException("You are not authorised to view this forum"); } } } } } else { Session[session] = ForumId.ToString(); } } } _currentForum.Roles = Forums.GetForumRoles(_currentForum.Id).ToList(); if (!IsAuthenticated && (_currentForum.Roles.Count > 0 && !_currentForum.Roles.Contains("All"))) { //if (Session[session] == null || Session[session].ToString() != ForumId.ToString()) throw new SecurityException("You must be logged in to view this forum"); } Session["IsAdminOrModerator"] = IsAdministrator || IsForumModerator; populate = PopulateData; //phPager.Controls.Add(_topicPager); Page.Title = string.Format(webResources.ttlForumPage, _currentForum.Subject, Config.ForumTitle); lblHotTopic.Text = string.Format(webResources.lblHotTopics, Config.HotTopicNum); string pagedescription = _currentForum.Description.CleanForumCodeTags(); metadescription.Text = String.Format("<meta name=\"description\" content=\"{0}\">", pagedescription); } else { //Response.Redirect("error.aspx?msg=errInvalidForumId", true); throw new HttpException(404, "Forum not found"); } InitializeStickyCollapse(); if (Request.Params["whichpage"] != null) { try { //_topicPager.CurrentIndex = Int32.Parse(Request.Params["whichpage"]) - 1; _topicPager.CurrentIndex = Int32.Parse(Request.Params["whichpage"]) - 1; } catch (Exception) { //Response.Redirect("error.aspx?msg=errInvalidPageNumber",true); throw new HttpException(404, "forum page not found"); } } if (!IsPostBack) { //create CacheKeyDependency if it does not exists if (Cache[TopicODS.CacheKeyDependency] == null || (int)Cache[TopicODS.CacheKeyDependency] != ForumId) { object obj = ForumId; Cache[TopicODS.CacheKeyDependency] = obj; } BindData(); } if (Page.IsPostBack) { string postbackbtn = Request.Form["__EVENTTARGET"]; string argument = Request.Form["__EVENTARGUMENT"]; int id; switch (postbackbtn) { case "LockTopic": id = Convert.ToInt32(argument); LockTopic(id); break; case "UnLockTopic": id = Convert.ToInt32(argument); UnLockTopic(id); break; case "DeleteTopic": id = Convert.ToInt32(argument); DeleteTopic(id); break; case "StickTopic": id = Convert.ToInt32(argument); StickTopic(id); break; case "UnStickTopic": id = Convert.ToInt32(argument); UnStickTopic(id); break; } } }
protected void Page_Load(object sender, EventArgs e) { if (CurrentPage == -1) CurrentPage = 0; if (ForumId != null) { _currentForum = Forums.GetForum(ForumId.Value); if (_currentForum == null) throw new ArgumentException("Invalid Forum ID"); if(_currentForum.Type == 1) { Response.Redirect(_currentForum.Url,true); } fLogin.forum = _currentForum; if (!IsPostBack) { if (IsAuthenticated) { //do we have access to this forum if (!Forums.IsUserInForumRole(Member.Username, ForumId.Value)) { if (Session[session] == null || Session[session].ToString() != ForumId.ToString()) { if (_currentForum.Password != null && !String.IsNullOrEmpty(_currentForum.Password.Trim())) { if (Session[session] == null || Session[session].ToString() == "") { var mp = (ModalPopupExtender) fLogin.FindControl("popup"); var masterPage = this.Page.Master; if (masterPage != null) { var cph = (ContentPlaceHolder) masterPage.FindControl("CPM"); cph.Visible = false; } mp.Show(); } else { if (Session[session].ToString() != ForumId.ToString()) throw new SecurityException("You are not authorised to view this forum"); } } } }else { Session[session] = ForumId.ToString(); } } } _currentForum.Roles = Forums.GetForumRoles(_currentForum.Id).ToList(); if (!IsAuthenticated && (_currentForum.Roles.Count > 0 && !_currentForum.Roles.Contains("All"))) { //if (Session[session] == null || Session[session].ToString() != ForumId.ToString()) throw new SecurityException("You must be logged in to view this forum"); } Session["IsAdminOrModerator"] = IsAdministrator || IsForumModerator; populate = PopulateData; //phPager.Controls.Add(_topicPager); Page.Title = string.Format(webResources.ttlForumPage, _currentForum.Subject, Config.ForumTitle); lblHotTopic.Text = string.Format(webResources.lblHotTopics, Config.HotTopicNum); string pagedescription = _currentForum.Description.CleanForumCodeTags(); metadescription.Text = String.Format("<meta name=\"description\" content=\"{0}\">", pagedescription); } else { //Response.Redirect("error.aspx?msg=errInvalidForumId", true); throw new HttpException(404,"Forum not found"); } InitializeStickyCollapse(); if (Request.Params["whichpage"] != null) { try { //_topicPager.CurrentIndex = Int32.Parse(Request.Params["whichpage"]) - 1; _topicPager.CurrentIndex = Int32.Parse(Request.Params["whichpage"]) - 1; } catch (Exception) { //Response.Redirect("error.aspx?msg=errInvalidPageNumber",true); throw new HttpException(404, "forum page not found"); } } if (!IsPostBack) { //create CacheKeyDependency if it does not exists if (Cache[TopicODS.CacheKeyDependency] == null || (int)Cache[TopicODS.CacheKeyDependency] != ForumId) { object obj = ForumId; Cache[TopicODS.CacheKeyDependency] = obj; } BindData(); } if (Page.IsPostBack) { string postbackbtn = Request.Form["__EVENTTARGET"]; string argument = Request.Form["__EVENTARGUMENT"]; int id; switch (postbackbtn) { case "LockTopic": id = Convert.ToInt32(argument); LockTopic(id); break; case "UnLockTopic": id = Convert.ToInt32(argument); UnLockTopic(id); break; case "DeleteTopic": id = Convert.ToInt32(argument); DeleteTopic(id); break; case "StickTopic": id = Convert.ToInt32(argument); StickTopic(id); break; case "UnStickTopic": id = Convert.ToInt32(argument); UnStickTopic(id); break; } } }