ASP. net mvc paging solution, asp. netmvc
When using Ajax. Pager for paging, pay attention to the following aspects:
1, be sure to introduce jquery. unobtrusive-ajax.min.js this js;
2. Be sure to use the register page splitter on the page. Registration Method: @ {Html. RegisterMvcPagerScriptResource ();};
Example:
<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 =>. setUpdateTargetId ("articles "). setHttpMethod ("Post "). setDataFormId ("searchView") </div> <div class = "col-md-4"> <div class = "input-group" style = "width: 120px; margin: 20 p x 0 "> <input type =" text "id =" pageIndexBox "class =" form-control "/> <span class =" input-group-btn "> <button class = "btn-primary" id = "goToBtn"> redirect </button> </span> </div>
Model is an IpagedList object. The method for obtaining PagerOptions is as follows:
/// <Summary> /// flip configuration item /// </summary> /// <returns> </returns> public PagerOptions GetPagerOption () {PagerOptions options = new PagerOptions {AutoHide = false, FirstPageText = "Homepage", LastPageText = "last page", NextPageText = "next page", PrevPageText = "Previous Page", 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 ;}
Currently, this control does not support displaying the total number of records and the total number of pages.
The above is all the content of this article. I hope it will be helpful for your learning and support for helping customers.