.net core 分页控件X.PagedList.Mvc.Core

nuget中在线安装X.PagedList.Mvc.Core

后端使用时引入 using X.PagedList;

异步返回 return View(await assetInfo.ToPagedListAsync(pageNumber, pageSize));//pageNumber:页数;pageSize:页面显示条数

前端分页页面需引入:

@model IPagedList<your Model>

@using X.PagedList.Mvc.Core; @*import this so we get our HTML Helper*@

@using X.PagedList; @*import this so we can cast our list to IPagedList (only necessary because ViewBag is dynamic)*@
@using X.PagedList.Mvc.Core.Fluent
@using X.PagedList.Web.Common

底部分页效果

 底部分页代码

@if (Model != null)
{
<span>本页 @Model.Count 条记录,当前第 @Model.PageNumber 页,共 @Model.PageCount 页,共 @Model.TotalItemCount 条记录。</span>
}
@*下述的action中type,value是为了实现get查询而做*@
@Html.PagedListPager(Model, page => Url.Action("AssetIndex", new { page, type = ViewBag.type, value = ViewBag.input_query, }))

如果导航效果不行,那最好到github获取x.pagedlist.mvc.core,然后将其中的css文件引用到页面就OK。

原文地址:https://www.cnblogs.com/chengcanghai/p/13870580.html