public static MvcHtmlString PagedListPagerWithSize(this System.Web.Mvc.HtmlHelper helper, IPagedList pagedList, Func <int, string> generatePageUrl, Func <int, string> generateSizeUrl, PagedListRenderOptions pageNumberOptions = null, PagedListSizeRenderOptions pageSizeOptions = null) { if (pageNumberOptions == null) { pageNumberOptions = new PagedListRenderOptions(); } if (pageSizeOptions == null) { pageSizeOptions = new PagedListSizeRenderOptions(); } var pagedListPart = helper.PagedListPager(pagedList, generatePageUrl, pageNumberOptions); var pagedSizeListPart = GeneratePageSizeList(pagedList, generateSizeUrl, pageSizeOptions); var outerWrapper = new TagBuilder("div"); outerWrapper.InnerHtml = pagedListPart.ToString() + pagedSizeListPart; return(new MvcHtmlString(outerWrapper.ToString())); }
public HtmlPagerBuilder(IHtmlHelper htmlHelper, IPagedList pagedList) { this._htmlHelper = htmlHelper; this._pagedList = pagedList; this._generatePageUrl = x => x.ToString(); this._options = new PagedListRenderOptions(); }
public static PagedListRenderOptions GetDefaultPagerOptions(bool isAjax) { PagedListRenderOptions result = null; var options = new PagedListRenderOptions() { DisplayLinkToFirstPage = PagedListDisplayMode.Always, DisplayLinkToLastPage = PagedListDisplayMode.Always, DisplayLinkToPreviousPage = PagedListDisplayMode.Always, DisplayLinkToNextPage = PagedListDisplayMode.Always, DisplayLinkToIndividualPages = true, ContainerDivClasses = null, //UlElementClasses = new[] { "pager" }, ClassToApplyToFirstListItemInPager = null, ClassToApplyToLastListItemInPager = null, LinkToPreviousPageFormat = "上一頁", LinkToNextPageFormat = "下一頁", LinkToFirstPageFormat = "首頁", LinkToLastPageFormat = "尾頁" }; if (isAjax) { result = PagedListRenderOptions.EnableUnobtrusiveAjaxReplacing(options, AjaxUtils.GetAjaxOptions()); } else { result = options; } return(options); }
public ActionResult listNews(string tag, int?page) { var groupnew = db.tblGroupNews.First(p => p.Tag == tag); int idcate = groupnew.id; var listnews = db.tblNews.Where(p => p.idCate == idcate && p.Active == true).OrderByDescending(p => p.Ord).ToList(); string chuoinewnew = ""; var NewsNew = db.tblNews.Where(p => p.Active == true && p.idCate != idcate).OrderByDescending(p => p.DateCreate).Take(5).ToList(); for (int i = 0; i < NewsNew.Count; i++) { chuoinewnew += "<li><a href=\"/tin-tuc/" + NewsNew[i].Tag + "\" title=\"" + NewsNew[i].Name + "\" rel=\"nofollow\"> " + NewsNew[i].Name + " <span>" + NewsNew[i].DateCreate + "</span></a></li>"; } ViewBag.chuoinewnews = chuoinewnew; string chuoichinhsach = ""; var Chinhsach = db.tblNews.Where(p => p.Active == true && p.idCate == 3).OrderByDescending(p => p.DateCreate).Take(5).ToList(); for (int i = 0; i < Chinhsach.Count; i++) { chuoichinhsach += "<li><a href=\"/tin-tuc/" + Chinhsach[i].Tag + "\" title=\"" + Chinhsach[i].Name + "\" rel=\"nofollow\"> " + Chinhsach[i].Name + " <span>" + Chinhsach[i].DateCreate + "</span></a></li>"; } ViewBag.chuoichinhsach = chuoichinhsach; const int pageSize = 10; var pageNumber = (page ?? 1); // Thiết lập phân trang var ship = new PagedListRenderOptions { DisplayLinkToFirstPage = PagedListDisplayMode.Always, DisplayLinkToLastPage = PagedListDisplayMode.Always, DisplayLinkToPreviousPage = PagedListDisplayMode.Always, DisplayLinkToNextPage = PagedListDisplayMode.Always, DisplayLinkToIndividualPages = true, DisplayPageCountAndCurrentLocation = false, MaximumPageNumbersToDisplay = 5, DisplayEllipsesWhenNotShowingAllPageNumbers = true, EllipsesFormat = "…", LinkToFirstPageFormat = "Trang đầu", LinkToPreviousPageFormat = "«", LinkToIndividualPageFormat = "{0}", LinkToNextPageFormat = "»", LinkToLastPageFormat = "Trang cuối", PageCountAndCurrentLocationFormat = "Page {0} of {1}.", ItemSliceAndTotalFormat = "Showing items {0} through {1} of {2}.", FunctionToDisplayEachPageNumber = null, ClassToApplyToFirstListItemInPager = null, ClassToApplyToLastListItemInPager = null, ContainerDivClasses = new[] { "pagination-container" }, UlElementClasses = new[] { "pagination" }, LiElementClasses = Enumerable.Empty <string>() }; ViewBag.ship = ship; ViewBag.Name = groupnew.Name; ViewBag.nUrl = "<a href=\"/\" title=\"Trang chủ\" rel=\"nofollow\"><span class=\"iCon\"></span> Trang chủ</a><i></i>" + UrlNews(groupnew.id); ViewBag.Title = "<title>" + groupnew.Title + "</title>"; ViewBag.Description = "<meta name=\"description\" content=\"" + groupnew.Description + "\"/>"; ViewBag.Keyword = "<meta name=\"keywords\" content=\"" + groupnew.Keyword + "\" /> "; return(View(listnews.ToPagedList(pageNumber, pageSize))); }
public ActionResult UserIndex(int?page) { var all = db.Users.OrderByDescending(u => u.ID).ToList(); int pageSize = 3; int pageNumber = (page ?? 1); // begin [get last page] if (page != null) { ViewBag.mPage = (int)page; } else { ViewBag.mPage = 1; } int lastPage = all.Count / pageSize; if (all.Count % pageSize > 0) { lastPage++; } ViewBag.LastPage = lastPage; ViewBag.PageSize = pageSize; //end [get last page] // Thiết lập phân trang PagedListRenderOptions pro = new PagedListRenderOptions(); pro.DisplayLinkToFirstPage = PagedListDisplayMode.Always; pro.DisplayLinkToLastPage = PagedListDisplayMode.Always; pro.DisplayLinkToPreviousPage = PagedListDisplayMode.Always; pro.DisplayLinkToNextPage = PagedListDisplayMode.Always; pro.DisplayLinkToIndividualPages = true; pro.DisplayPageCountAndCurrentLocation = false; pro.MaximumPageNumbersToDisplay = 5; pro.DisplayEllipsesWhenNotShowingAllPageNumbers = true; pro.EllipsesFormat = "…"; pro.LinkToFirstPageFormat = "Trang đầu"; pro.LinkToPreviousPageFormat = "«"; pro.LinkToIndividualPageFormat = "{0}"; pro.LinkToNextPageFormat = "»"; pro.LinkToLastPageFormat = "Trang cuối"; pro.PageCountAndCurrentLocationFormat = "Page {0} of {1}."; pro.ItemSliceAndTotalFormat = "Showing items {0} through {1} of {2}."; pro.FunctionToDisplayEachPageNumber = null; pro.ClassToApplyToFirstListItemInPager = null; pro.ClassToApplyToLastListItemInPager = null; pro.ContainerDivClasses = new[] { "pagination-container" }; pro.UlElementClasses = new[] { "pagination" }; pro.LiElementClasses = Enumerable.Empty <string>(); ViewBag.Pro = pro; return(View(all.ToPagedList(pageNumber, pageSize))); }
private static void SetPageNumbersPlusFirstAndLastOption(PagedListRenderOptions option) { option.DisplayLinkToFirstPage = PagedListDisplayMode.Always; option.DisplayLinkToLastPage = PagedListDisplayMode.Always; option.DisplayLinkToPreviousPage = PagedListDisplayMode.Never; option.DisplayLinkToNextPage = PagedListDisplayMode.Never; option.DisplayLinkToIndividualPages = true; }
private static void SetFullOption(PagedListRenderOptions option) { option.DisplayLinkToFirstPage = PagedListDisplayMode.Always; option.DisplayLinkToLastPage = PagedListDisplayMode.Always; option.DisplayLinkToPreviousPage = PagedListDisplayMode.Always; option.DisplayLinkToNextPage = PagedListDisplayMode.Always; option.DisplayLinkToIndividualPages = true; }
private static void SetMinimalOption(PagedListRenderOptions option) { option.DisplayLinkToFirstPage = PagedListDisplayMode.Never; option.DisplayLinkToLastPage = PagedListDisplayMode.Never; option.DisplayLinkToPreviousPage = PagedListDisplayMode.Always; option.DisplayLinkToNextPage = PagedListDisplayMode.Always; option.DisplayLinkToIndividualPages = false; }
public ActionResult ListMenufacturers(int?page, string tag) { var ListManFacturers = db.tblAgencies.Where(p => p.Active == true).OrderByDescending(p => p.Ord).ToList(); ViewBag.Name = "Hệ thống phân phối"; ViewBag.Title = "<title>Hệ thống phân phối Viglacera</title>"; ViewBag.Description = "<meta name=\"description\" content=\"Hệ thống phân phối chính hãng sản phẩm thiết bị vệ sinh Viglacera trên toàn quốc. Địa chỉ : 391 - Nguyễn Xiển - Thanh Xuân - HN\"/>"; ViewBag.Keyword = "<meta name=\"keywords\" content=\"Hệ thống phân phối thiết bị vệ sinh Viglacera\" /> "; if (tag != "" && tag != null) { int idMenu; string Chuoi = tag; string[] Mang = Chuoi.Split('-'); int one = int.Parse(Mang.Length.ToString()); string chuoi1 = Mang[one - 1].ToString(); string[] Mang1 = chuoi1.Split('.'); idMenu = int.Parse(Mang1[0].ToString()); tblGroupAgency groupnew = db.tblGroupAgencies.Find(idMenu); ViewBag.Name = groupnew.Name; ViewBag.Title = "<title>" + groupnew.Name + "</title>"; ViewBag.Description = "<meta name=\"description\" content=\"" + groupnew.Description + "\"/>"; ViewBag.Keyword = "<meta name=\"keywords\" content=\"" + groupnew.Name + "\" /> "; ListManFacturers = db.tblAgencies.Where(p => p.Active == true && p.idMenu == idMenu).OrderByDescending(p => p.Ord).ToList(); } const int pageSize = 10; var pageNumber = (page ?? 1); // Thiết lập phân trang var ship = new PagedListRenderOptions { DisplayLinkToFirstPage = PagedListDisplayMode.Always, DisplayLinkToLastPage = PagedListDisplayMode.Always, DisplayLinkToPreviousPage = PagedListDisplayMode.Always, DisplayLinkToNextPage = PagedListDisplayMode.Always, DisplayLinkToIndividualPages = true, DisplayPageCountAndCurrentLocation = false, MaximumPageNumbersToDisplay = 5, DisplayEllipsesWhenNotShowingAllPageNumbers = true, EllipsesFormat = "…", LinkToFirstPageFormat = "Trang đầu", LinkToPreviousPageFormat = "«", LinkToIndividualPageFormat = "{0}", LinkToNextPageFormat = "»", LinkToLastPageFormat = "Trang cuối", PageCountAndCurrentLocationFormat = "Page {0} of {1}.", ItemSliceAndTotalFormat = "Showing items {0} through {1} of {2}.", FunctionToDisplayEachPageNumber = null, ClassToApplyToFirstListItemInPager = null, ClassToApplyToLastListItemInPager = null, ContainerDivClasses = new[] { "pagination-container" }, UlElementClasses = new[] { "pagination" }, LiElementClasses = Enumerable.Empty <string>() }; ViewBag.ship = ship; return(View(ListManFacturers.ToPagedList(pageNumber, pageSize))); }
public ActionResult listNews(string tag, int?page) { TblGroupNews groupnews = db.TblGroupNews.First(p => p.Tag == tag); ViewBag.Title = "<title>" + groupnews.Title + "</title>"; ViewBag.Description = "<meta name=\"description\" content=\"" + groupnews.Description + "\"/>"; ViewBag.Keyword = "<meta name=\"keywords\" content=\"" + groupnews.Keyword + "\" /> "; int idcate = int.Parse(groupnews.Id.ToString()); ViewBag.Name = groupnews.Name; var Listnews = db.TblNews.Where(p => p.IdCate == idcate && p.Active == true).OrderByDescending(p => p.DateCreate).ToList(); const int pageSize = 20; var pageNumber = (page ?? 1); // Thiết lập phân trang var ship = new PagedListRenderOptions { DisplayLinkToFirstPage = PagedListDisplayMode.Always, DisplayLinkToLastPage = PagedListDisplayMode.Always, DisplayLinkToPreviousPage = PagedListDisplayMode.Always, DisplayLinkToNextPage = PagedListDisplayMode.Always, DisplayLinkToIndividualPages = true, DisplayPageCountAndCurrentLocation = false, MaximumPageNumbersToDisplay = 5, DisplayEllipsesWhenNotShowingAllPageNumbers = true, EllipsesFormat = "…", LinkToFirstPageFormat = "Trang đầu", LinkToPreviousPageFormat = "«", LinkToIndividualPageFormat = "{0}", LinkToNextPageFormat = "»", LinkToLastPageFormat = "Trang cuối", PageCountAndCurrentLocationFormat = "Page {0} of {1}.", ItemSliceAndTotalFormat = "Showing items {0} through {1} of {2}.", FunctionToDisplayEachPageNumber = null, ClassToApplyToFirstListItemInPager = null, ClassToApplyToLastListItemInPager = null, ContainerDivClasses = new[] { "pagination-container" }, UlElementClasses = new[] { "pagination" }, LiElementClasses = Enumerable.Empty <string>() }; ViewBag.ship = ship; ViewBag.name = groupnews.Name; ViewBag.nUrl = "<ol itemscope itemtype=\"http://schema.org/BreadcrumbList\"> <li itemprop=\"itemListElement\" itemscope itemtype=\"http://schema.org/ListItem\"> <a itemprop=\"item\" href=\"http://Bontana.vn\"> <span itemprop=\"name\">Trang chủ</span></a> <meta itemprop=\"position\" content=\"1\" /> </li> ›" + Urlnews(idcate) + "</ol>"; ViewBag.favicon = " <link href=\"" + db.TblConfig.First().Favicon + "\" rel=\"icon\" type=\"image/x-icon\" />"; var tblconfig = db.TblConfig.FirstOrDefault(); ViewBag.color = tblconfig.Color; Listnews = db.TblNews.Where(p => p.IdCate == idcate && p.Active == true).OrderByDescending(p => p.DateCreate).ToList(); return(View(Listnews.ToPagedList(pageNumber, pageSize))); }
private ITagBuilder PageCountAndLocationText(IPagedList list, PagedListRenderOptions options) { var text = _tagBuilderFactory .Create("a"); SetInnerText(text, string.Format(options.PageCountAndCurrentLocationFormat, list.PageNumber, list.PageCount)); return(WrapInListItem(text, options, "PagedList-pageCountAndLocation", "disabled")); }
private ITagBuilder ItemSliceAndTotalText(IPagedList list, PagedListRenderOptions options) { var text = _tagBuilderFactory .Create("a"); SetInnerText(text, string.Format(options.ItemSliceAndTotalFormat, list.FirstItemOnPage, list.LastItemOnPage, list.TotalItemCount)); return(WrapInListItem(text, options, "PagedList-pageCountAndLocation", "disabled")); }
public ActionResult SizeIndex(int?page, string currentSizeName) { if (Request.HttpMethod == "GET") { if (Session["SizeName"] != null) { currentSizeName = Session["SizeName"].ToString(); Session["SizeName"] = null; } } else { page = 1; } ViewBag.CurrentSizeName = currentSizeName; var all = db.sp_Size_GetByAll().OrderBy(p => p.Ord).ToList(); if (!String.IsNullOrEmpty(currentSizeName)) { all = all.Where(p => p.Name.ToUpper().Contains(currentSizeName.ToUpper())).OrderBy(p => p.Ord).ToList(); } int pageSize = 25; int pageNumber = (page ?? 1); // Thiết lập phân trang PagedListRenderOptions ship = new PagedListRenderOptions(); ship.DisplayLinkToFirstPage = PagedListDisplayMode.Always; ship.DisplayLinkToLastPage = PagedListDisplayMode.Always; ship.DisplayLinkToPreviousPage = PagedListDisplayMode.Always; ship.DisplayLinkToNextPage = PagedListDisplayMode.Always; ship.DisplayLinkToIndividualPages = true; ship.DisplayPageCountAndCurrentLocation = false; ship.MaximumPageNumbersToDisplay = 5; ship.DisplayEllipsesWhenNotShowingAllPageNumbers = true; ship.EllipsesFormat = "…"; ship.LinkToFirstPageFormat = "Trang đầu"; ship.LinkToPreviousPageFormat = "«"; ship.LinkToIndividualPageFormat = "{0}"; ship.LinkToNextPageFormat = "»"; ship.LinkToLastPageFormat = "Trang cuối"; ship.PageCountAndCurrentLocationFormat = "Page {0} of {1}."; ship.ItemSliceAndTotalFormat = "Showing items {0} through {1} of {2}."; ship.FunctionToDisplayEachPageNumber = null; ship.ClassToApplyToFirstListItemInPager = null; ship.ClassToApplyToLastListItemInPager = null; ship.ContainerDivClasses = new[] { "pagination-container" }; ship.UlElementClasses = new[] { "pagination" }; ship.LiElementClasses = Enumerable.Empty <string>(); ViewBag.ship = ship; return(View(all.ToPagedList(pageNumber, pageSize))); }
public PartialViewResult partialImages(int?page, string text, string idCate, string pageSizes) { var ListImages = db.tblImages.OrderByDescending(p => p.Ord).ToList(); int pageSize = 20; var pageNumber = (page ?? 1); // Thiết lập phân trang var ship = new PagedListRenderOptions { DisplayLinkToFirstPage = PagedListDisplayMode.Always, DisplayLinkToLastPage = PagedListDisplayMode.Always, DisplayLinkToPreviousPage = PagedListDisplayMode.Always, DisplayLinkToNextPage = PagedListDisplayMode.Always, DisplayLinkToIndividualPages = true, DisplayPageCountAndCurrentLocation = false, MaximumPageNumbersToDisplay = 5, DisplayEllipsesWhenNotShowingAllPageNumbers = true, EllipsesFormat = "…", LinkToFirstPageFormat = "Trang đầu", LinkToPreviousPageFormat = "«", LinkToIndividualPageFormat = "{0}", LinkToNextPageFormat = "»", LinkToLastPageFormat = "Trang cuối", PageCountAndCurrentLocationFormat = "Page {0} of {1}.", ItemSliceAndTotalFormat = "Showing items {0} through {1} of {2}.", FunctionToDisplayEachPageNumber = null, ClassToApplyToFirstListItemInPager = null, ClassToApplyToLastListItemInPager = null, ContainerDivClasses = new[] { "pagination-container" }, UlElementClasses = new[] { "pagination" }, LiElementClasses = Enumerable.Empty <string>() }; ViewBag.ship = ship; if (pageSizes != null) { ViewBag.pageSizes = pageSizes; pageSize = int.Parse(pageSizes.ToString()); ViewBag.chuoicout = "<span style='color: #A52A2A;'>" + pageSize + "</span> / <span style='color: #333;'>" + ListImages.Count.ToString() + "</span>"; return(PartialView(ListImages.ToPagedList(pageNumber, pageSize))); } if (idCate != "" && idCate != null) { int idmenu = int.Parse(idCate); ListImages = db.tblImages.Where(p => p.idCate == idmenu).OrderByDescending(m => m.Ord).ToList(); ViewBag.Idcha = idCate; ViewBag.idCate = idCate; return(PartialView(ListImages.ToPagedList(pageNumber, pageSize))); } else { ViewBag.Idcha = 0; } return(PartialView(ListImages.ToPagedList(pageNumber, pageSize))); }
/// <summary> /// Set bootstrap4 style for raw <see cref="PagedListRenderOptions"/> /// </summary> /// <param name="options"></param> /// <returns></returns> public static PagedListRenderOptions ApplyBootstrap4Style(this PagedListRenderOptions options) { options.LiElementClasses = new[] { "page-item" }; options.PageClasses = new[] { "page-link" }; // Due to no way change Ellipses element class, try setting EllipsesElementClass but fail, so disable Ellipses options.DisplayEllipsesWhenNotShowingAllPageNumbers = false; return(options); }
///<summary> /// Displays a configurable paging control for instances of PagedList. ///</summary> ///<param name = "html">This method is meant to hook off HtmlHelper as an extension method.</param> ///<param name = "list">The PagedList to use as the data source.</param> ///<param name = "generatePageUrl">A function that takes the page number of the desired page and returns a URL-string that will load that page.</param> ///<param name = "options">Formatting options.</param> ///<returns>Outputs the paging control HTML.</returns> public static HtmlString PagedListPager(this IHtmlHelper html, IPagedList list, Func <int, string> generatePageUrl, PagedListRenderOptions options) { var htmlHelper = new HtmlHelper(new TagBuilderFactory()); var htmlString = htmlHelper.PagedListPager(list, generatePageUrl, options); return(new HtmlString(htmlString)); }
public ActionResult List(int?page) { if (Request.HttpMethod == "GET") { } else { page = 1; } #region [Phân trang] int pageSize = 15; int pageNumber = (page ?? 1); // Thiết lập phân trang PagedListRenderOptions ship = new PagedListRenderOptions(); ship.DisplayLinkToFirstPage = PagedListDisplayMode.Always; ship.DisplayLinkToLastPage = PagedListDisplayMode.Always; ship.DisplayLinkToPreviousPage = PagedListDisplayMode.Always; ship.DisplayLinkToNextPage = PagedListDisplayMode.Always; ship.DisplayLinkToIndividualPages = true; ship.DisplayPageCountAndCurrentLocation = false; ship.MaximumPageNumbersToDisplay = 5; ship.DisplayEllipsesWhenNotShowingAllPageNumbers = true; ship.EllipsesFormat = "…"; ship.LinkToFirstPageFormat = "Trang đầu"; ship.LinkToPreviousPageFormat = "«"; ship.LinkToIndividualPageFormat = "{0}"; ship.LinkToNextPageFormat = "»"; ship.LinkToLastPageFormat = "Trang cuối"; ship.PageCountAndCurrentLocationFormat = "Page {0} of {1}."; ship.ItemSliceAndTotalFormat = "Showing items {0} through {1} of {2}."; ship.FunctionToDisplayEachPageNumber = null; ship.ClassToApplyToFirstListItemInPager = null; ship.ClassToApplyToLastListItemInPager = null; ship.ContainerDivClasses = new[] { "pagination-container" }; ship.UlElementClasses = new[] { "pagination" }; ship.LiElementClasses = Enumerable.Empty <string>(); ViewBag.ship = ship; #endregion string chuoi = ""; #region [Title, Keyword, Deskription] var listconfig = (from p in data.Configs select p).ToList(); if (listconfig.Count > 0) { ViewBag.tit = listconfig[0].Title; ViewBag.des = listconfig[0].Description; ViewBag.key = listconfig[0].Keyword; } listconfig.Clear(); listconfig = null; #endregion var list = (from n in data.News where n.Active == true orderby n.IdGroup, n.Id descending select n).ToList(); return(View(list.ToPagedList(pageNumber, pageSize))); }
public ActionResult AgencyList(string tag, int?page) { int idMenu; string Chuoi = tag; string[] Mang = Chuoi.Split('-'); int one = int.Parse(Mang.Length.ToString()); string chuoi1 = Mang[one - 1].ToString(); string[] Mang1 = chuoi1.Split('.'); idMenu = int.Parse(Mang1[0].ToString()); tblGroupAgency groupagency = db.tblGroupAgencies.Find(idMenu); int idCate = groupagency.id; var LisstAgency = db.tblAgencies.Where(p => p.Active == true).OrderByDescending(p => p.Ord).ToList(); ViewBag.Name = groupagency.Name; ViewBag.Title = "<title>" + groupagency.Name + "</title>"; ViewBag.Description = "<meta name=\"description\" content=\"" + groupagency.Description + "\"/>"; ViewBag.Keyword = "<meta name=\"keywords\" content=\"" + groupagency.Name + "\" /> "; ViewBag.nUrl = "<a href=\"/\" title=\"Trang chu\" rel=\"nofollow\"><span class=\"iCon\"></span>Trang chủ</a> /" + groupagency.Name; const int pageSize = 12; var pageNumber = (page ?? 1); // Thiết lập phân trang var ship = new PagedListRenderOptions { DisplayLinkToFirstPage = PagedListDisplayMode.Always, DisplayLinkToLastPage = PagedListDisplayMode.Always, DisplayLinkToPreviousPage = PagedListDisplayMode.Always, DisplayLinkToNextPage = PagedListDisplayMode.Always, DisplayLinkToIndividualPages = true, DisplayPageCountAndCurrentLocation = false, MaximumPageNumbersToDisplay = 5, DisplayEllipsesWhenNotShowingAllPageNumbers = true, EllipsesFormat = "…", LinkToFirstPageFormat = "Trang đầu", LinkToPreviousPageFormat = "«", LinkToIndividualPageFormat = "{0}", LinkToNextPageFormat = "»", LinkToLastPageFormat = "Trang cuối", PageCountAndCurrentLocationFormat = "Page {0} of {1}.", ItemSliceAndTotalFormat = "Showing items {0} through {1} of {2}.", FunctionToDisplayEachPageNumber = null, ClassToApplyToFirstListItemInPager = null, ClassToApplyToLastListItemInPager = null, ContainerDivClasses = new[] { "pagination-container" }, UlElementClasses = new[] { "pagination" }, LiElementClasses = Enumerable.Empty <string>() }; ViewBag.ship = ship; return(View(LisstAgency.ToPagedList(pageNumber, pageSize))); }
private static void SetBootstrap4Option(PagedListRenderOptions option) { option.ContainerHtmlTag = DefaultContainerHtmlTag; option.UlElementClasses = DefaultUlElementClasses; option.LiElementClasses = DefaultLiElementClasses; option.AhrefElementClasses = DefaultAhrefElementClasses; option.LinkToPreviousPageFormat = DefaultLinkToPreviousPageFormat; option.LinkToNextPageFormat = DefaultLinkToNextPageFormat; option.LinkToFirstPageFormat = DefaultLinkToFirstPageFormat; option.LinkToLastPageFormat = DefaultLinkToLastPageFormat; }
public PartialViewResult partialGuarantee(int?page, string id, string idCate) { int ids = int.Parse(id); var ListQuarantee = db.tblGuarantees.Where(p => p.idDistrict == ids).ToList(); if (idCate != null && idCate != "") { ViewBag.idCate = idCate; int idCates = int.Parse(idCate); ListQuarantee = ListQuarantee.Where(p => p.idManu == idCates).ToList(); } const int pageSize = 20; var pageNumber = (page ?? 1); // Thiết lập phân trang var ship = new PagedListRenderOptions { DisplayLinkToFirstPage = PagedListDisplayMode.Always, DisplayLinkToLastPage = PagedListDisplayMode.Always, DisplayLinkToPreviousPage = PagedListDisplayMode.Always, DisplayLinkToNextPage = PagedListDisplayMode.Always, DisplayLinkToIndividualPages = true, DisplayPageCountAndCurrentLocation = false, MaximumPageNumbersToDisplay = 5, DisplayEllipsesWhenNotShowingAllPageNumbers = true, EllipsesFormat = "…", LinkToFirstPageFormat = "Trang đầu", LinkToPreviousPageFormat = "«", LinkToIndividualPageFormat = "{0}", LinkToNextPageFormat = "»", LinkToLastPageFormat = "Trang cuối", PageCountAndCurrentLocationFormat = "Page {0} of {1}.", ItemSliceAndTotalFormat = "Showing items {0} through {1} of {2}.", FunctionToDisplayEachPageNumber = null, ClassToApplyToFirstListItemInPager = null, ClassToApplyToLastListItemInPager = null, ContainerDivClasses = new[] { "pagination-container" }, UlElementClasses = new[] { "pagination" }, LiElementClasses = Enumerable.Empty <string>() }; ViewBag.ship = ship; if (id != "") { ViewBag.idCate = id; ViewBag.idMenu = id; } else { } return(PartialView(ListQuarantee.ToPagedList(pageNumber, pageSize))); }
private static PagedListRenderOptions GetCommonSetting() { var option = new PagedListRenderOptions() { LiElementClasses = new[] { "page-item" }, PageClasses = new[] { "page-link" }, // Due to no way change Ellipses element class, try setting EllipsesElementClass but fail, so disable Ellipses DisplayEllipsesWhenNotShowingAllPageNumbers = false }; return(option); }
public ActionResult ListNews(string tag, int?page, string id) { int idCate = int.Parse(db.tblGroupNews.First(p => p.Tag == tag).id.ToString()); var listnews = db.tblNews.Where(p => p.idCate == idCate && p.Active == true).OrderByDescending(p => p.Ord).ToList(); const int pageSize = 20; var pageNumber = (page ?? 1); // Thiết lập phân trang var ship = new PagedListRenderOptions { DisplayLinkToFirstPage = PagedListDisplayMode.Always, DisplayLinkToLastPage = PagedListDisplayMode.Always, DisplayLinkToPreviousPage = PagedListDisplayMode.Always, DisplayLinkToNextPage = PagedListDisplayMode.Always, DisplayLinkToIndividualPages = true, DisplayPageCountAndCurrentLocation = false, MaximumPageNumbersToDisplay = 5, DisplayEllipsesWhenNotShowingAllPageNumbers = true, EllipsesFormat = "…", LinkToFirstPageFormat = "Trang đầu", LinkToPreviousPageFormat = "«", LinkToIndividualPageFormat = "{0}", LinkToNextPageFormat = "»", LinkToLastPageFormat = "Trang cuối", PageCountAndCurrentLocationFormat = "Page {0} of {1}.", ItemSliceAndTotalFormat = "Showing items {0} through {1} of {2}.", FunctionToDisplayEachPageNumber = null, ClassToApplyToFirstListItemInPager = null, ClassToApplyToLastListItemInPager = null, ContainerDivClasses = new[] { "pagination-container" }, UlElementClasses = new[] { "pagination" }, LiElementClasses = Enumerable.Empty <string>() }; ViewBag.ship = ship; var groupnew = db.tblGroupNews.First(p => p.Tag == tag); //int dodai = groupnew.Level.Length / 5; //string nUrl = ""; //for (int i = 0; i < dodai; i++) //{ // var NameGroups = db.tblGroupNews.First(p => p.Level.Substring(0, (i + 1) * 5) == groupnew.Level.Substring(0, (i + 1) * 5) && p.Level.Length == (i + 1) * 5); // nUrl = nUrl + " <a href=\"/2/" + NameGroups.Tag + "\" title=\"" + NameGroups.Name + "\"> " + " " + NameGroups.Name + "</a> /"; //} ViewBag.nUrl = "<a href=\"/\" title=\"Trang chủ\" rel=\"nofollow\"><span class=\"iCon\"></span> Trang chủ</a> /" + UrlNews(idCate); ViewBag.Title = "<title>" + groupnew.Title + "</title>"; ViewBag.Description = "<meta name=\"description\" content=\"" + groupnew.Description + "\"/>"; ViewBag.Keyword = "<meta name=\"keywords\" content=\"" + groupnew.Keyword + "\" /> "; ViewBag.Name = groupnew.Name; return(View(listnews.ToPagedList(pageNumber, pageSize))); }
public static PagedListRenderOptions CustomAjax(string updateTargetId) { return(PagedListRenderOptions.EnableUnobtrusiveAjaxReplacing( new PagedListRenderOptions() { DisplayItemSliceAndTotal = true, ItemSliceAndTotalFormat = "Mostrando itens {0} a {1} de {2}." }, new AjaxOptions() { HttpMethod = "GET", UpdateTargetId = updateTargetId })); }
public static MvcHtmlString PaginationFor(this HtmlHelper html, IPagedList list, Func <int, string> generatePageUrl, string updateTargetId = "mainContent") { var listItems = new List <SelectListItem> { new SelectListItem { Text = "30", Value = "30" }, new SelectListItem { Text = "50", Value = "50" }, new SelectListItem { Text = "100", Value = "100" }, new SelectListItem { Text = "200", Value = "200" } }; var isDisplay = new PagedListRenderOptions { Display = PagedListDisplayMode.IfNeeded }; var ajaxOption = new AjaxOptions { HttpMethod = "GET", UpdateTargetId = updateTargetId }; var pageOption = PagedListRenderOptions.EnableUnobtrusiveAjaxReplacing(isDisplay, ajaxOption); var pgn = html.PagedListPager(list, generatePageUrl, pageOption); var url = "loadPagination('" + generatePageUrl.Invoke(1) + "','" + updateTargetId + "'," + "this" + ")"; var drop = html.DropDownList("PageSize", new SelectList(listItems, "Value", "Text"), new { @class = "form-control pagination-dropdown ", onchange = "url()" }); var result = list.HasNextPage ? string.Format("<div class='row'>" + "<div class='col-md-4'>" + "<div class='form-group' style='width: 200px;'>" + "<label for='PageSize'>Page Size : </label>{0}" + "</div>" + "</div>" + "<div class='col-md-8'>{1}</div>" + "</div>", drop, pgn) : string.Format("<div class='row'><div class='col-md-12'>{0}</div></div>", pgn); result = result.Replace("url()", url); return(MvcHtmlString.Create(result)); }
public static PagedListRenderOptions GetPagedListRenderOptions() { PagedListRenderOptions options = new PagedListRenderOptions() { LinkToPreviousPageFormat = "上一页", LinkToNextPageFormat = "下一页", LinkToFirstPageFormat = "首页", LinkToLastPageFormat = "尾页", DisplayLinkToNextPage = PagedListDisplayMode.Always, DisplayLinkToPreviousPage = PagedListDisplayMode.Always, DisplayLinkToFirstPage = PagedListDisplayMode.Always, DisplayLinkToLastPage = PagedListDisplayMode.Always }; return(options); }
/// <summary> /// Enables ASP.NET MVC's unobtrusive AJAX feature. An XHR request will retrieve HTML from the clicked page and replace the innerHtml of the provided element ID. /// </summary> /// <param name="options">The preferred Html.PagedList(...) style options.</param> /// <param name="ajaxOptions">The ajax options that will put into the link</param> /// <returns>The PagedListRenderOptions value passed in, with unobtrusive AJAX attributes added to the page links.</returns> public static PagedListRenderOptions EnableUnobtrusiveAjaxReplacing(PagedListRenderOptions options, AjaxOptions ajaxOptions) { options.FunctionToTransformEachPageLink = (liTagBuilder, aTagBuilder) => { var liClass = liTagBuilder.Attributes.ContainsKey("class") ? liTagBuilder.Attributes["class"] ?? "" : ""; if (ajaxOptions != null && !liClass.Contains("disabled") && !liClass.Contains("active")) { foreach (var ajaxOption in ajaxOptions.ToUnobtrusiveHtmlAttributes()) { aTagBuilder.Attributes.Add(ajaxOption.Key, ajaxOption.Value.ToString()); } } liTagBuilder.InnerHtml = aTagBuilder.ToString(); return(liTagBuilder); }; return(options); }
public ActionResult newsTag(string tag, int?page) { const int pageSize = 10; var pageNumber = (page ?? 1); var ship = new PagedListRenderOptions { DisplayLinkToFirstPage = PagedListDisplayMode.Always, DisplayLinkToLastPage = PagedListDisplayMode.Always, DisplayLinkToPreviousPage = PagedListDisplayMode.Always, DisplayLinkToNextPage = PagedListDisplayMode.Always, DisplayLinkToIndividualPages = true, DisplayPageCountAndCurrentLocation = false, MaximumPageNumbersToDisplay = 5, DisplayEllipsesWhenNotShowingAllPageNumbers = true, EllipsesFormat = "…", LinkToFirstPageFormat = "Trang đầu", LinkToPreviousPageFormat = "«", LinkToIndividualPageFormat = "{0}", LinkToNextPageFormat = "»", LinkToLastPageFormat = "Trang cuối", PageCountAndCurrentLocationFormat = "Page {0} of {1}.", ItemSliceAndTotalFormat = "Showing items {0} through {1} of {2}.", FunctionToDisplayEachPageNumber = null, ClassToApplyToFirstListItemInPager = null, ClassToApplyToLastListItemInPager = null, ContainerDivClasses = new[] { "pagination-container" }, UlElementClasses = new[] { "pagination" }, LiElementClasses = Enumerable.Empty <string>() }; ViewBag.ship = ship; string name = db.tblNewsTags.Where(p => p.Tag == tag).Take(1).ToList()[0].Name; ViewBag.Name = name; var listidNews = db.tblNewsTags.Where(p => p.Tag == tag).Select(p => p.idn).ToList(); var listnews = db.tblNews.Where(p => p.Active == true && listidNews.Contains(p.id)).OrderByDescending(p => p.DateCreate).ToList(); ViewBag.nUrl = " <ol itemscope itemtype=\"http://schema.org/BreadcrumbList\" > <li itemprop=\"itemListElement\" itemscope itemtype=\"http://schema.org/ListItem\"><a itemprop=\"item\" href=\"/\"> <span itemprop=\"name\">Trang chủ</span></a> <meta itemprop=\"position\" content=\"1\" /> </li> › </ol><h2>" + name + "</h2>"; ViewBag.Title = "<title>" + name + "</title>"; ViewBag.Description = "<meta name=\"description\" content=\"" + name + "\"/>"; ViewBag.Keyword = "<meta name=\"keywords\" content=\"" + name + "\" /> "; return(View(listnews.ToPagedList(pageNumber, pageSize))); }
public ActionResult listAgency(int?page) { var listAgency = db.tblAgencies.Where(p => p.Active == true).OrderByDescending(p => p.Ord).ToList(); const int pageSize = 10; var pageNumber = (page ?? 1); // Thiết lập phân trang var ship = new PagedListRenderOptions { DisplayLinkToFirstPage = PagedListDisplayMode.Always, DisplayLinkToLastPage = PagedListDisplayMode.Always, DisplayLinkToPreviousPage = PagedListDisplayMode.Always, DisplayLinkToNextPage = PagedListDisplayMode.Always, DisplayLinkToIndividualPages = true, DisplayPageCountAndCurrentLocation = false, MaximumPageNumbersToDisplay = 5, DisplayEllipsesWhenNotShowingAllPageNumbers = true, EllipsesFormat = "…", LinkToFirstPageFormat = "Trang đầu", LinkToPreviousPageFormat = "«", LinkToIndividualPageFormat = "{0}", LinkToNextPageFormat = "»", LinkToLastPageFormat = "Trang cuối", PageCountAndCurrentLocationFormat = "Page {0} of {1}.", ItemSliceAndTotalFormat = "Showing items {0} through {1} of {2}.", FunctionToDisplayEachPageNumber = null, ClassToApplyToFirstListItemInPager = null, ClassToApplyToLastListItemInPager = null, ContainerDivClasses = new[] { "pagination-container" }, UlElementClasses = new[] { "pagination" }, LiElementClasses = Enumerable.Empty <string>() }; ViewBag.ship = ship; ViewBag.Name = "Danh sách đại lý lõi lọc nước"; ViewBag.nUrl = "<a href=\"/\" title=\"Trang chủ\" rel=\"nofollow\"><span class=\"iCon\"></span> Trang chủ</a><i></i> / Đại lý lõi lọc nước"; ViewBag.Title = "<title>Danh sách đại lý lõi lọc nước</title>"; ViewBag.Description = "<meta name=\"description\" content=\"Danh sách đại lý lõi lọc nước chính hãng thuộc Loiloc.com. Hệ thống Lõi lọc nước có mặt tại 63 tỉnh thành trên toàn quốc \"/>"; ViewBag.Keyword = "<meta name=\"keywords\" content=\"Đại lý lõi lọc nước\" /> "; return(View(listAgency.ToPagedList(pageNumber, pageSize))); }
public ActionResult ListCatalogues(int?page) { var ListCatalogues = db.tblFiles.Where(p => p.Cate == 0 && p.Active == true).OrderByDescending(p => p.Ord).ToList(); const int pageSize = 20; var pageNumber = (page ?? 1); // Thiết lập phân trang var ship = new PagedListRenderOptions { DisplayLinkToFirstPage = PagedListDisplayMode.Always, DisplayLinkToLastPage = PagedListDisplayMode.Always, DisplayLinkToPreviousPage = PagedListDisplayMode.Always, DisplayLinkToNextPage = PagedListDisplayMode.Always, DisplayLinkToIndividualPages = true, DisplayPageCountAndCurrentLocation = false, MaximumPageNumbersToDisplay = 5, DisplayEllipsesWhenNotShowingAllPageNumbers = true, EllipsesFormat = "…", LinkToFirstPageFormat = "Trang đầu", LinkToPreviousPageFormat = "«", LinkToIndividualPageFormat = "{0}", LinkToNextPageFormat = "»", LinkToLastPageFormat = "Trang cuối", PageCountAndCurrentLocationFormat = "Page {0} of {1}.", ItemSliceAndTotalFormat = "Showing items {0} through {1} of {2}.", FunctionToDisplayEachPageNumber = null, ClassToApplyToFirstListItemInPager = null, ClassToApplyToLastListItemInPager = null, ContainerDivClasses = new[] { "pagination-container" }, UlElementClasses = new[] { "pagination" }, LiElementClasses = Enumerable.Empty <string>() }; ViewBag.ship = ship; ViewBag.Title = "<title>Tổng hợp catalogues sản phẩm Thiết bị vệ sinh TOTO</title>"; ViewBag.Description = "<meta name=\"description\" content=\"Bộ danh sách những catalogues sản phẩm Thiết bị vệ sinh TOTO chính hãng đầy đủ dành cho khách hàng\"/>"; ViewBag.Keyword = "<meta name=\"keywords\" content=\"Catalogues toto, Báo giá catalogues\" /> "; return(View(ListCatalogues.ToPagedList(pageNumber, pageSize))); }
public ActionResult TabsAgency(string tag, int?page) { var ListAgency = db.tblAgencies.Where(p => p.Tabs.Contains(tag) && p.Active == true).OrderByDescending(p => p.DateCreate).ToList(); const int pageSize = 20; var pageNumber = (page ?? 1); // Thiết lập phân trang var ship = new PagedListRenderOptions { DisplayLinkToFirstPage = PagedListDisplayMode.Always, DisplayLinkToLastPage = PagedListDisplayMode.Always, DisplayLinkToPreviousPage = PagedListDisplayMode.Always, DisplayLinkToNextPage = PagedListDisplayMode.Always, DisplayLinkToIndividualPages = true, DisplayPageCountAndCurrentLocation = false, MaximumPageNumbersToDisplay = 5, DisplayEllipsesWhenNotShowingAllPageNumbers = true, EllipsesFormat = "…", LinkToFirstPageFormat = "Trang đầu", LinkToPreviousPageFormat = "«", LinkToIndividualPageFormat = "{0}", LinkToNextPageFormat = "»", LinkToLastPageFormat = "Trang cuối", PageCountAndCurrentLocationFormat = "Page {0} of {1}.", ItemSliceAndTotalFormat = "Showing items {0} through {1} of {2}.", FunctionToDisplayEachPageNumber = null, ClassToApplyToFirstListItemInPager = null, ClassToApplyToLastListItemInPager = null, ContainerDivClasses = new[] { "pagination-container" }, UlElementClasses = new[] { "pagination" }, LiElementClasses = Enumerable.Empty <string>() }; ViewBag.ship = ship; ViewBag.name = tag; ViewBag.Title = "<title>" + tag + "</title>"; ViewBag.Description = "<meta name=\"description\" content=\"" + tag + "\"/>"; ViewBag.Keyword = "<meta name=\"keywords\" content=\"" + tag + "\" /> "; ViewBag.favicon = " <link href=\"" + db.tblConfigs.First().Favicon + "\" rel=\"icon\" type=\"image/x-icon\" />"; return(View(ListAgency.ToPagedList(pageNumber, pageSize))); }
private static TagBuilder Last(IPagedList list, Func<int, string> generatePageUrl, PagedListRenderOptions options) { var targetPageNumber = list.PageCount; var last = new TagBuilder("a") { InnerHtml = string.Format(options.LinkToLastPageFormat, targetPageNumber) }; if (list.IsLastPage) return WrapInListItem(last, options, "PagedList-skipToLast", "disabled"); last.Attributes["href"] = generatePageUrl(targetPageNumber); return WrapInListItem(last, options, "PagedList-skipToLast"); }
private static TagBuilder PageCountAndLocationText(IPagedList list, PagedListRenderOptions options) { var text = new TagBuilder("a"); text.SetInnerText(string.Format(options.PageCountAndCurrentLocationFormat, list.PageNumber, list.PageCount)); return WrapInListItem(text, options, "PagedList-pageCountAndLocation", "disabled"); }
private static TagBuilder Page(int i, IPagedList list, Func<int, string> generatePageUrl, PagedListRenderOptions options) { var format = options.FunctionToDisplayEachPageNumber ?? (pageNumber => string.Format(options.LinkToIndividualPageFormat, pageNumber)); var targetPageNumber = i; var page = new TagBuilder("a"); page.SetInnerText(format(targetPageNumber)); if (i == list.PageNumber) return WrapInListItem(page, options, "active"); page.Attributes["href"] = generatePageUrl(targetPageNumber); return WrapInListItem(page, options); }
private static TagBuilder WrapInListItem(TagBuilder inner, PagedListRenderOptions options, params string[] classes) { //var li = new TagBuilder("li"); //foreach (var @class in classes) // li.AddCssClass(@class); //if (options.FunctionToTransformEachPageLink != null) // return options.FunctionToTransformEachPageLink(li, inner); //li.InnerHtml = inner.ToString(); foreach (var @class in classes) inner.AddCssClass(@class); return inner; }
public ListViewModel() { PageSize = 25; RenderOptions = new PagedListRenderOptions(); ModelState = new ModelStateDictionary(); }
///<summary> /// Displays a configurable paging control for instances of PagedList. ///</summary> ///<param name = "html">This method is meant to hook off HtmlHelper as an extension method.</param> ///<param name = "list">The PagedList to use as the data source.</param> ///<param name = "generatePageUrl">A function that takes the page number of the desired page and returns a URL-string that will load that page.</param> ///<param name = "options">Formatting options.</param> ///<returns>Outputs the paging control HTML.</returns> public static MvcHtmlString PagedListPager(this System.Web.Mvc.HtmlHelper html, IPagedList list, Func<int, string> generatePageUrl, PagedListRenderOptions options) { var listItemLinks = new List<TagBuilder>(); //first if (options.DisplayLinkToFirstPage) listItemLinks.Add(First(list, generatePageUrl, options)); //previous if (options.DisplayLinkToPreviousPage) listItemLinks.Add(Previous(list, generatePageUrl, options)); //text if (options.DisplayPageCountAndCurrentLocation) listItemLinks.Add(PageCountAndLocationText(list, options)); //text if (options.DisplayItemSliceAndTotal) listItemLinks.Add(ItemSliceAndTotalText(list, options)); //page if (options.DisplayLinkToIndividualPages) { //calculate start and end of range of page numbers var start = 1; var end = list.PageCount; if (options.MaximumPageNumbersToDisplay.HasValue && list.PageCount > options.MaximumPageNumbersToDisplay) { var maxPageNumbersToDisplay = options.MaximumPageNumbersToDisplay.Value; start = list.PageNumber - maxPageNumbersToDisplay / 2; if (start < 1) start = 1; end = maxPageNumbersToDisplay; if ((start + end - 1) > list.PageCount) start = list.PageCount - maxPageNumbersToDisplay + 1; } //if there are previous page numbers not displayed, show an ellipsis if (options.DisplayEllipsesWhenNotShowingAllPageNumbers && start > 1) listItemLinks.Add(Ellipses(options)); foreach (var i in Enumerable.Range(start, end)) { //show delimiter between page numbers if (i > start && !string.IsNullOrWhiteSpace(options.DelimiterBetweenPageNumbers)) listItemLinks.Add(WrapInListItem(options.DelimiterBetweenPageNumbers)); //show page number link listItemLinks.Add(Page(i, list, generatePageUrl, options)); } //if there are subsequent page numbers not displayed, show an ellipsis if (options.DisplayEllipsesWhenNotShowingAllPageNumbers && (start + end - 1) < list.PageCount) listItemLinks.Add(Ellipses(options)); } //next if (options.DisplayLinkToNextPage) listItemLinks.Add(Next(list, generatePageUrl, options)); //last if (options.DisplayLinkToLastPage) listItemLinks.Add(Last(list, generatePageUrl, options)); //append class to first item in list? if (!string.IsNullOrWhiteSpace(options.ClassToApplyToFirstListItemInPager)) listItemLinks.First().AddCssClass(options.ClassToApplyToFirstListItemInPager); //append class to last item in list? if (!string.IsNullOrWhiteSpace(options.ClassToApplyToLastListItemInPager)) listItemLinks.Last().AddCssClass(options.ClassToApplyToLastListItemInPager); //append classes to all list item links foreach (var li in listItemLinks) foreach (var c in options.LiElementClasses ?? Enumerable.Empty<string>()) li.AddCssClass(c); //collapse all of the list items into one big string var listItemLinksString = listItemLinks.Aggregate( new StringBuilder(), (sb, listItem) => sb.Append(listItem.ToString()), sb => sb.ToString() ); var ul = new TagBuilder("ul") { InnerHtml = listItemLinksString }; foreach (var c in options.UlElementClasses ?? Enumerable.Empty<string>()) ul.AddCssClass(c); var outerDiv = new TagBuilder("div"); foreach (var c in options.ContainerDivClasses ?? Enumerable.Empty<string>()) outerDiv.AddCssClass(c); outerDiv.InnerHtml = ul.ToString(); return new MvcHtmlString(outerDiv.ToString()); }
private static TagBuilder ItemSliceAndTotalText(IPagedList list, PagedListRenderOptions options) { var text = new TagBuilder("a"); text.SetInnerText(string.Format(options.ItemSliceAndTotalFormat, list.FirstItemOnPage, list.LastItemOnPage, list.TotalItemCount)); return WrapInListItem(text, options, "PagedList-pageCountAndLocation", "disabled"); }
/// <summary> /// Displays a configurable paging control for instances of PagedList. /// </summary> /// <param name="html">This method is meant to hook off HtmlHelper as an extension method.</param> /// <param name="list">The PagedList to use as the data source.</param> /// <param name="formId">Id of the firm, which is used to submit data.</param> /// <param name="routeValues">Additional parameters to pass to server.</param> /// <param name="actionUrl">Url for the form where it should submit.</param> /// <param name="validation">Should or not form validate data in form.</param> /// <returns></returns> public static MvcHtmlString DVSPagedListPager(this System.Web.Mvc.HtmlHelper html, IPagedList list, string formId, Func<int, RouteValueDictionary> routeValues, string actionUrl, ValidationType validation = ValidationType.None) { if (list == null) throw new ArgumentNullException("list"); if (routeValues == null) throw new ArgumentNullException("routeValues"); if (String.IsNullOrWhiteSpace(actionUrl)) throw new ArgumentNullException("actionUrl"); if (String.IsNullOrWhiteSpace(formId)) throw new ArgumentNullException("formId"); var options = new PagedListRenderOptions { LinkToPreviousPageFormat = "<", LinkToNextPageFormat = ">", DisplayLinkToFirstPage = true, LinkToFirstPageFormat = "1", DisplayLinkToLastPage = true, LinkToLastPageFormat = list.PageCount.ToString(), EllipsesFormat = "..", MaximumPageNumbersToDisplay = 5, ContainerDivClasses = new string[] { "PagedList-pager" } }; var jsHelper = new JavaScriptHelper(); Func<int, string> pageAction = page => jsHelper.GetSubmitScript(formId, routeValues(page), actionUrl, validation); return DVSPagedListPager(html, list, pageAction, options); }
private static TagBuilder Previous(IPagedList list, Func<int, string> generatePageUrl, PagedListRenderOptions options) { var targetPageNumber = list.PageNumber - 1; var previous = new TagBuilder("a") { InnerHtml = string.Format(options.LinkToPreviousPageFormat, targetPageNumber) }; if (!list.HasPreviousPage) return WrapInListItem(previous, options, "PagedList-skipToPrevious", "disabled"); previous.Attributes["href"] = generatePageUrl(targetPageNumber); return WrapInListItem(previous, options, "PagedList-skipToPrevious"); }
private static TagBuilder Next(IPagedList list, Func<int, string> generatePageUrl, PagedListRenderOptions options) { var targetPageNumber = list.PageNumber + 1; var next = new TagBuilder("a") { InnerHtml = string.Format(options.LinkToNextPageFormat, targetPageNumber) }; if (!list.HasNextPage) return WrapInListItem(next, options, "PagedList-skipToNext", "disabled"); next.Attributes["href"] = generatePageUrl(targetPageNumber); return WrapInListItem(next, options, "PagedList-skipToNext"); }
private static TagBuilder Ellipses(PagedListRenderOptions options) { var a = new TagBuilder("a") { InnerHtml = options.EllipsesFormat }; return WrapInListItem(a, options, "PagedList-ellipses", "disabled"); }