demo: https://github.com/StoneIsDeveloper/AjaxPageLIST.git
使用场景:
@Html.PagedListPager(...) 实现分页,或异步分页
Refrerences: PagedList, PagedList.Mvc
实现普通分页的方式比较简单:
@Html.PagedListPager(
Model.PublicPages,
page => Url.Action("PublicNews", "Home", new { page = page }),
new PagedListRenderOptions
{
Display = PagedListDisplayMode.IfNeeded,
MaximumPageNumbersToDisplay = 5,
})
PageListRenderOptions 配置对象 可以对分页进行一些基础的显示设置
现在我们要启用Ajax模式
@Html.PagedListPager(
Model.PublicPages,
page => Url.Action("PublicNews", "Home", new { page = page }),
PagedListRenderOptions.EnableUnobtrusiveAjaxReplacing(
ASP.NET MVC异步分页实现:PageList.Mvc与Ajax

本文介绍了如何使用PageList.Mvc库结合Ajax实现异步分页。通过引用PagedList和PagedList.Mvc库,利用PagedListRenderOptions.EnableUnobtrusiveAjaxReplacing方法设置Ajax选项,并确保引入jquery.unobtrusive-ajax.js。在Controller中,针对Ajax请求返回Partial View以更新分页内容。
最低0.47元/天 解锁文章

211

被折叠的 条评论
为什么被折叠?



