ASP.NET MVC分頁問題解決
在使用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">跳轉(zhuǎn)</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;
}
目前所知,該控件不支持顯示記錄總數(shù)及總頁數(shù)。
以上就是本文的全部內(nèi)容,希望對大家的學習有所幫助,也希望大家多多支持腳本之家。
- ASP.NET同步分頁MvcPager使用詳解
- asp.net mvc4 mysql制作簡單分頁組件(部分視圖)
- asp.net MVC分頁代碼分享
- ASP.NET MVC4 Razor模板簡易分頁效果
- ASP.NET MVC分頁和排序功能實現(xiàn)
- 利用ASP.NET MVC+Bootstrap搭建個人博客之打造清新分頁Helper(三)
- ASP.NET MVC+EF在服務端分頁使用jqGrid以及jquery Datatables的注意事項
- ASP.NET MVC4 HtmlHelper擴展類,實現(xiàn)分頁功能
- ASP.NET MVC 2右鍵菜單和簡單分頁實例講解
- ASP.NET MVC 5使用X.PagedList.Mvc進行分頁教程(PagedList.Mvc)
相關文章
SignalR Self Host+MVC等多端消息推送服務(二)
這篇文章主要為大家詳細介紹了SignalR Self Host+MVC等多端消息推送服務的第二篇,具有一定的參考價值,感興趣的小伙伴們可以參考一下2017-06-06
asp.net DataGridView導出到Excel的三個方法[親測]
打開Excel并將DataGridView控件中數(shù)據(jù)導出到Excel的幾種方法2008-08-08
MongoDB.Net工具庫MongoRepository使用方法詳解
這篇文章主要為大家詳細介紹了MongoDB.Net工具庫MongoRepository的使用方法,具有一定的參考價值,感興趣的小伙伴們可以參考一下2018-01-01
MVC默認路由實現(xiàn)分頁(PagerExtend.dll下載)
這篇文章主要介紹了MVC默認路由實現(xiàn)分頁,采用bootstrap的樣式,文末提供了PagerExtend.dll下載地址,感興趣的小伙伴們可以參考一下2016-07-07
ASP.NET(C#) Web Api通過文件流下載文件的實例
這篇文章主要介紹了ASP.NET(C#) Web Api通過文件流下載文件的方法,提供源碼下載,需要的朋友可以參考下。2016-06-06
ASP.NET連接數(shù)據(jù)庫并獲取數(shù)據(jù)方法總結
這篇文章主要介紹了ASP.NET連接數(shù)據(jù)庫并獲取數(shù)據(jù)方法,結合實例分析總結了ASP.NET連接數(shù)據(jù)庫及獲取數(shù)據(jù)的相關實現(xiàn)技巧,并附帶了web.config配置文件的使用方法與相關注意事項,需要的朋友可以參考下2015-11-11

