基于BootStrap实现局部刷新分页实例代码

在之前的工作中我用的分页有很多,一直不牢固,所以自己用起来也不是很顺手,这是一个局部刷新的分页,我试了很多,本想用mvcPager来做局部刷新,但是考虑到成本太高,放弃了,先来总结一下基于bootstrap的分页吧,便于自己以后使用

开源地址

首先引用

Jquery

bootstrap.min.js

bootstrap-paginator.min.js

控制器代码

rush:js;"> [AuthorizationCodeAttribute] [Description("评论信息")] [HttpPost] public ActionResult Comment(int id,int? page) { #region 评论列表 var dal = new CarCommentOperator(); int pageIndex = page ?? 1;//当前页 if (!string.IsNullOrEmpty(Request.QueryString["pageindex"])) { if (!int.TryParse(Request.QueryString["pageindex"],out pageIndex)) { pageIndex = 1; } } const int pageSize = 2; long totalCount; long totalPageCount; IEnumerable list = dal.GetList(pageIndex,pageSize,out totalPageCount,out totalCount,"CarId=" + id); var commentIPagedList = new StaticPagedList(list,pageIndex,Convert.ToInt32(totalCount)); #endregion //转成Json格式 var strResult = "{\"pageCount\":" + commentIPagedList.PageCount + ",\"CurrentPage\":" + commentIPagedList.PageNumber + ",\"list\":" + JsonConvert.SerializeObject(list) + "}"; return Json(strResult,JsonRequestBehavior.AllowGet); }

js代码

rush:js;">