protected void Page_Load(object sender, EventArgs e) { var settings = ForumManager.GetSettings(SettingsID); Topics = new List <Topic>(); if (ThreadID == 0) { Response.Redirect(settings.StartPageAbsolutePath); } int currentPageNumber = 0; if (!String.IsNullOrEmpty(Request["p"])) { try { currentPageNumber = Convert.ToInt32(Request["p"]); } catch { currentPageNumber = 0; } } if (currentPageNumber <= 0) { currentPageNumber = 1; } int topicCountInThread = 0; Topics = ForumDataProvider.GetTopics(TenantProvider.CurrentTenantID, SecurityContext.CurrentAccount.ID, ThreadID, currentPageNumber, settings.TopicCountOnPage, out topicCountInThread); ForumDataProvider.SetThreadVisit(TenantProvider.CurrentTenantID, ThreadID); int i = 0; foreach (Topic topic in Topics) { TopicControl topicControl = (TopicControl)LoadControl(settings.UserControlsVirtualPath + "/TopicControl.ascx"); topicControl.Topic = topic; topicControl.SettingsID = SettingsID; topicControl.IsEven = (i % 2 == 0); this.topicListHolder.Controls.Add(topicControl); i++; } PageNavigator pageNavigator = new PageNavigator() { PageUrl = settings.LinkProvider.TopicList(ThreadID), CurrentPageNumber = currentPageNumber, EntryCountOnPage = settings.TopicCountOnPage, VisiblePageCount = 5, EntryCount = topicCountInThread }; bottomPageNavigatorHolder.Controls.Add(pageNavigator); }
protected void Page_Load(object sender, EventArgs e) { var settings = ForumManager.GetSettings(SettingsID); PageSize = string.IsNullOrEmpty(Request["size"]) ? 20 : Convert.ToInt32(Request["size"]); //var pageSize = PageSize; Topics = new List <Topic>(); if (ThreadID == 0) { Response.Redirect(settings.StartPageAbsolutePath); } int currentPageNumber = 0; if (!String.IsNullOrEmpty(Request["p"])) { try { currentPageNumber = Convert.ToInt32(Request["p"]); } catch { currentPageNumber = 0; } } if (currentPageNumber <= 0) { currentPageNumber = 1; } int topicCountInThread = 0; Topics = ForumDataProvider.GetTopics(TenantProvider.CurrentTenantID, SecurityContext.CurrentAccount.ID, ThreadID, currentPageNumber, PageSize, out topicCountInThread); ForumDataProvider.SetThreadVisit(TenantProvider.CurrentTenantID, ThreadID); int i = 0; foreach (Topic topic in Topics) { TopicControl topicControl = (TopicControl)LoadControl(settings.UserControlsVirtualPath + "/TopicControl.ascx"); topicControl.Topic = topic; topicControl.SettingsID = SettingsID; topicControl.IsEven = (i % 2 == 0); this.topicListHolder.Controls.Add(topicControl); i++; } PageSize = string.IsNullOrEmpty(Request["size"]) ? 20 : Convert.ToInt32(Request["size"]); var pageSize = PageSize; PageNavigator pageNavigator = new PageNavigator() { PageUrl = string.Format( CultureInfo.CurrentCulture, "{0}?&f={1}&size={2}", VirtualPathUtility.ToAbsolute("~/products/community/modules/forum/topics.aspx"), ThreadID, pageSize ), //settings.LinkProvider.TopicList(ThreadID), CurrentPageNumber = currentPageNumber, EntryCountOnPage = pageSize, //settings.TopicCountOnPage, VisiblePageCount = 5, EntryCount = topicCountInThread }; TopicPagesCount = pageNavigator.EntryCount; var pageCount = (int)(TopicPagesCount / pageSize + 1); if (pageCount < pageNavigator.CurrentPageNumber) { pageNavigator.CurrentPageNumber = pageCount; } bottomPageNavigatorHolder.Controls.Add(pageNavigator); InitScripts(); }