Skip to content

Commit ee3b97f

Browse files
committed
Merge remote-tracking branch 'origin/master'
2 parents febe421 + 26efcc3 commit ee3b97f

File tree

2 files changed

+21
-2
lines changed

2 files changed

+21
-2
lines changed

examples/X.PagedList.Mvc.Example.Core/Views/Bootstrap41/_NameListPartial.cshtml

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,20 @@
1515
}
1616
</ul>
1717

18-
@Html.PagedListPager((IPagedList<string>)ViewBag.Names, page => Url.Action("GetOnePageOfNames", new { page }), PagedListRenderOptions.EnableUnobtrusiveAjaxReplacing(new PagedListRenderOptions { MaximumPageNumbersToDisplay = 5, DisplayPageCountAndCurrentLocation = true, UlElementClasses = new[] { "pagination" }, ContainerDivClasses = new[] { "pagination-container" } }, new AjaxOptions() { HttpMethod = "GET", UpdateTargetId = "nameListContainer" }))
18+
@Html.PagedListPager(
19+
(IPagedList<string>)ViewBag.Names,
20+
page => Url.Action("GetOnePageOfNames", new { page }),
21+
PagedListRenderOptions.EnableUnobtrusiveAjaxReplacing(
22+
new PagedListRenderOptions
23+
{
24+
MaximumPageNumbersToDisplay = 5,
25+
DisplayPageCountAndCurrentLocation = true,
26+
UlElementClasses = new[] { "pagination" },
27+
ContainerDivClasses = new[] { "pagination-container" }
28+
},
29+
new AjaxOptions()
30+
{
31+
HttpMethod = "GET",
32+
UpdateTargetId = "nameListContainer"
33+
})
34+
)

src/X.PagedList.Mvc.Core/Common/HtmlHelper.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
using System;
22
using System.Collections.Generic;
3+
using System.Collections.Immutable;
34
using System.Linq;
45
using System.Text;
56

@@ -270,8 +271,10 @@ private ITagBuilder NextEllipsis(IPagedList list, Func<int, string> generatePage
270271

271272
#endregion Private methods
272273

273-
public string PagedListPager(IPagedList list, Func<int, string> generatePageUrl, PagedListRenderOptions options)
274+
public string PagedListPager(IPagedList pagedList, Func<int, string> generatePageUrl, PagedListRenderOptions options)
274275
{
276+
var list = pagedList ?? new StaticPagedList<int>(ImmutableList<int>.Empty, 1, 10, 0);
277+
275278
if (options.Display == PagedListDisplayMode.Never || (options.Display == PagedListDisplayMode.IfNeeded && list.PageCount <= 1))
276279
{
277280
return null;

0 commit comments

Comments
 (0)