ASP.NET MVC分页问题解决
网络编程 2021-07-04 22:41www.168986.cn编程入门
这篇文章主要为大家详细介绍了ASP.NET MVC分页问题的解决方法,Ajax.Pager分页的使用注意事项,具有一定的参考价值,感兴趣的小伙伴们可以参考一下
在使用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; }
目前所知,该控件不支持显示记录总数及总页数。
以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持狼蚁SEO。
编程语言
- 机械手焊接机器人编程 机械手焊接设备编程
- vb数据库编程实例,vb做数据库
- tiobe世界编程语言排行榜,全球编程语言排行
- 成都java编程培训 成都it编程培训中心
- 编程基础培训,编程基础知识培训
- flash游戏编程基础教程,flash游戏开发教程
- 不会英语能学编程吗 不会英语可以学程序员吗
- 爱心代码编程C语言 爱心代码编程c语言公式
- c语言编程学习入门 c语言编程快速入门
- 西门子plc编程培训 西门子plc编程培训班
- 哪里可以学编程 台州哪里可以学编程
- 少儿编程哪个好 少儿编程哪个品牌好
- 编程是什么意思,图形编程是什么意思
- c语言编程软件下载,c语言编程软件在哪下载
- java编程软件下载,java编程下载手机版
- ug编程培训学校,ug编程培训教程