protected void Page_Load(object sender, EventArgs e) { AjaxPro.Utility.RegisterTypeForAjax(typeof(Blog)); member = (Member)Session["Member"]; if (member != null) { IsLoggedIn = true; } ViewingMember = ExtractPageParams.GetMember(this.Page, this.Context); string strPager = Request.Params["p"]; strBlogID = Request.Params["b"]; try { string [] blogID = strBlogID.Split(new char[] { ',' }); if (blogID.Length != 0) { strBlogID = blogID[blogID.Length - 1]; } } catch {} Int32.TryParse(strPager, out PageTo); PageTo = (PageTo == 0) ? 1 : PageTo; if (member != null) { if (ViewingMember.WebMemberID == member.WebMemberID) { IsMyPage = true; } } if (ViewingMember != null) { blogs = BlogEntry.GetBlogEntryByMemberID(ViewingMember.WebMemberID); blogs = SortBlogsByDate(blogs); } if (blogs.Count == 0) { return; } HasContent = true; int i = 1; if (strBlogID != null) { foreach (BlogEntry b in blogs) { if (b.WebBlogEntryID == strBlogID) { blog = b; PageTo = i; break; } i++; } } else { if (PageTo > blogs.Count) { PageTo = blogs.Count; } blog = blogs[PageTo - 1]; } if (blog != null) { strBlogID = blog.WebBlogEntryID; WebBlogID = blog.WebBlogEntryID; Comments1.ObjectId = blog.BlogEntryID; Comments1.ObjectWebId = blog.WebBlogEntryID; Comments1.CommentType = CommentType.Blog; PopulateVariables(); BlogPager pager = new BlogPager("/users/" + ViewingMember.NickName + "/blog/", ViewingMember.NickName + "/", PageTo, blogs.Count); pager.PageSize = 1; DefaultHTMLPager = (blogs.Count > 0) ? "<span>" + pager.ToString() + "</span>" : string.Empty; } }
protected void Page_Load(object sender, EventArgs e) { AjaxPro.Utility.RegisterTypeForAjax(typeof(Blog)); member = (Member)Session["Member"]; if (member != null) { IsLoggedIn = true; } ViewingMember = ExtractPageParams.GetMember(this.Page, this.Context); string strPager = Request.Params["p"]; strBlogID = Request.Params["b"]; try { string []blogID = strBlogID.Split(new char[]{','}); if (blogID.Length != 0) { strBlogID = blogID[blogID.Length - 1]; } } catch{} Int32.TryParse(strPager, out PageTo); PageTo = (PageTo == 0) ? 1 : PageTo; if (member != null) { if (ViewingMember.WebMemberID == member.WebMemberID) { IsMyPage = true; } } if (ViewingMember != null) { blogs = BlogEntry.GetBlogEntryByMemberID(ViewingMember.WebMemberID); blogs = SortBlogsByDate(blogs); } if (blogs.Count == 0) { return; } HasContent = true; int i = 1; if (strBlogID != null) { foreach (BlogEntry b in blogs) { if (b.WebBlogEntryID == strBlogID) { blog = b; PageTo = i; break; } i++; } } else { if (PageTo > blogs.Count) PageTo = blogs.Count; blog = blogs[PageTo - 1]; } if (blog != null) { strBlogID = blog.WebBlogEntryID; WebBlogID = blog.WebBlogEntryID; Comments1.ObjectId = blog.BlogEntryID; Comments1.ObjectWebId = blog.WebBlogEntryID; Comments1.CommentType = CommentType.Blog; PopulateVariables(); BlogPager pager = new BlogPager("/users/" + ViewingMember.NickName + "/blog/", ViewingMember.NickName + "/", PageTo, blogs.Count); pager.PageSize = 1; DefaultHTMLPager = (blogs.Count > 0) ? "<span>" + pager.ToString() + "</span>" : string.Empty; } }
protected virtual void SetupBlogPager(int recordsPerPage, int totalRecordCount, Dictionary <string, string> urlFilters) { BlogPager blogLandingPager = new BlogPager(); int currentPage = 0; string olderText = "< Older Posts"; string newerText = "Newer Posts >"; if (PageAssemblyContext.Current.PageAssemblyInstruction.GetField("Language") == "es") { olderText = "< Artículos anteriores"; newerText = "Artículos siguientes >"; } blogLandingPager.RecordCount = totalRecordCount; blogLandingPager.RecordsPerPage = recordsPerPage; if (string.IsNullOrEmpty(this.Page.Request.Params["page"])) { currentPage = 1; } else { currentPage = Int32.Parse(this.Page.Request.Params["page"]); } blogLandingPager.CurrentPage = currentPage; blogLandingPager.BaseUrl = PageInstruction.GetUrl(PageAssemblyInstructionUrls.PrettyUrl).ToString(); blogLandingPager.PageParamName = "page"; blogLandingPager.CssClass = "blog-pager clearfix"; blogLandingPager.PagerStyleSettings.NextPageCssClass = "older"; blogLandingPager.PagerStyleSettings.NextPageText = olderText; blogLandingPager.PagerStyleSettings.PrevPageCssClass = "newer"; blogLandingPager.PagerStyleSettings.PrevPageText = newerText; string searchQueryParams = string.Empty; if (this.SearchList.SearchType.ToLower() == "keyword" || this.SearchList.SearchType.ToLower() == "keyword_with_date") { searchQueryParams = "?keyword=" + Server.HtmlEncode(KeyWords); } if (this.SearchList.SearchType.ToLower() == "date" || this.SearchList.SearchType.ToLower() == "keyword_with_date") { if (string.IsNullOrEmpty(searchQueryParams)) { searchQueryParams = "?"; } else { searchQueryParams += "&"; } if (StartDate != DateTime.MinValue && EndDate != DateTime.MaxValue) { searchQueryParams += string.Format("startMonth={0}&startyear={1}&endMonth={2}&endYear={3}", StartDate.Month, StartDate.Year, EndDate.Month, EndDate.Year); } else { searchQueryParams += "startMonth=&startyear=&endMonth=&endYear="; } } foreach (KeyValuePair <string, string> entry in urlFilters) { if (string.IsNullOrEmpty(searchQueryParams)) { searchQueryParams = "?"; } else { searchQueryParams += "&"; } searchQueryParams += string.Format("filter[{0}]={1}", entry.Key, entry.Value); } blogLandingPager.BaseUrl += searchQueryParams; Controls.Add(blogLandingPager); // check for existence of previous and and next urls string prevUrl = blogLandingPager.GetPrevLinkUrl(); string nextUrl = blogLandingPager.GetNextLinkUrl(); if (prevUrl != null) { this.PageInstruction.AddUrlFilter("RelPrev", (name, url) => { url.SetUrl(prevUrl); }); } if (nextUrl != null) { this.PageInstruction.AddUrlFilter("RelNext", (name, url) => { url.SetUrl(nextUrl); }); } }