您现在的位置是:网站首页> 编程资料编程资料

ASP.NET MVC分页问题解决_实用技巧_

2023-05-24 405人已围观

简介 ASP.NET MVC分页问题解决_实用技巧_

在使用Ajax.Pager进行分页的时候需要注意一下几个方面:

  1、一定要引入jquery.unobtrusive-ajax.min.js这个js;

  2、一定要在页面中使用注册分页器,注册方法:@{Html.RegisterMvcPagerScriptResource();};

具体的使用方法示例:

@{ PagerConfig pagerConfig = new PagerConfig("pageIndex", "pageIndexBox", "goToBtn"); PagerOptions options = pagerConfig.GetPagerOption(); } @Ajax.Pager(Model, options).AjaxOptions(a => a.SetUpdateTargetId("articles").SetHttpMethod("Post").SetDataFormId("searchView"))

其中Model是IpagedList对象,获取PagerOptions的方法如下:

 ///  /// 翻页配置项 ///  ///  public PagerOptions GetPagerOption() { PagerOptions options = new PagerOptions { AutoHide = false, FirstPageText = "首页", LastPageText = "尾页", NextPageText = "下一页", PrevPageText = "上一页", PageIndexParameterName = this._pageIndexParaName, ContainerTagName = "ul", CssClass = "pagination", CurrentPagerItemTemplate = "
  • {0}
  • ", DisabledPagerItemTemplate = "
  • {0}
  • ", PagerItemTemplate = "
  • {0}
  • ", PageIndexBoxId = this._pageIndexBoxId, GoToButtonId = this._goToButtonId, NumericPagerItemCount = 5 }; return options; }

    目前所知,该控件不支持显示记录总数及总页数。

    以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持。

    -六神源码网