ASP.NET MVC分页问题解决
时间:2017-11-22|栏目:im钱包|点击: 次
在使用Ajax.Pager进行分页的时候需要注意一下几个方面:
1、一定要引入jquery.unobtrusive-ajax.min.js这个js;
2、一定要在页面中使用注册分页器,注册方法:@{Html.RegisterMvcPagerScriptResource();};
具体的使用方法示例:
|
<div class="row" style="position: relative; left: 30%">
<div class="col-md-8" style="width: auto">
@{
PagerConfig pagerConfig = new PagerConfig("pageIndex", "pageIndexBox", "goToBtn");
PagerOptions options = pagerConfig.GetPagerOption();
}
@Ajax.Pager(Model, options).AjaxOptions(a => a.SetUpdateTargetId("articles").SetHttpMethod("Post").SetDataFormId("searchView"))
</div>
<div class="col-md-4">
<div class="input-group" style="width: 120px; margin: 20px 0">
<input type="text" id="pageIndexBox" class="form-control" />
<span class="input-group-btn"><button class="btn btn-primary" id="goToBtn">跳转</button></span>
</div>
</div>
</div>
|
其中Model是IpagedList对象,获取PagerOptions的方法如下:
|
/// <summary>
/// 翻页配置项
/// </summary>
/// <returns></returns>
public PagerOptions GetPagerOption()
{
PagerOptions options = new PagerOptions
{
AutoHide = false,
FirstPageText = "首页",
LastPageText = "尾页",
NextPageText = "下一页",
PrevPageText = "上一页",
PageIndexParameterName = this._pageIndexParaName,
ContainerTagName = "ul",
CssClass = "pagination",
CurrentPagerItemTemplate = "<li class=\"active\"><a href=\"#\">{0}</a></li>",
DisabledPagerItemTemplate = "<li class=\"disabled\"><a>{0}</a></li>",
PagerItemTemplate = "<li>{0}</li>",
PageIndexBoxId = this._pageIndexBoxId,
GoToButtonId = this._goToButtonId,
NumericPagerItemCount = 5
};
return options;
}
|
目前所知,该控件不支持显示记录总数及总页数。
您可能感兴趣的文章


阅读排行
推荐教程
- 08-01imtoken钱包im下载理财年化
- 08-01比特币后期im官网走势图最新
- 08-01TrustWallet钱imToken包被盗转款
- 07-19比特币钱包im官网对接java
- 06-05快捷币钱包imToken下载使用方法
- 05-03以太坊行情imToken钱包阐明2022
- 05-03比特币钱包im下载都有什么用
- 05-03苹果比特币im官网钱包有哪些
- 05-03怎么找比特imToken官网下载币钱包文件
- 04-23imtoken官网imToken钱包下载ios 安装




