一個(gè)asp net MVC 的分頁代碼

一個(gè)asp net MVC 的分頁代碼

ID:40577669

大小:17.10 KB

頁數(shù):4頁

時(shí)間:2019-08-04

一個(gè)asp net MVC 的分頁代碼_第1頁
一個(gè)asp net MVC 的分頁代碼_第2頁
一個(gè)asp net MVC 的分頁代碼_第3頁
一個(gè)asp net MVC 的分頁代碼_第4頁
資源描述:

《一個(gè)asp net MVC 的分頁代碼》由會(huì)員上傳分享,免費(fèi)在線閱讀,更多相關(guān)內(nèi)容在教育資源-天天文庫。

1、一個(gè)asp.netMVC的分頁代碼  首先聲明,這個(gè)分頁代碼并不是出自我手哈,借用了網(wǎng)上的一段代碼,然后加了個(gè)css,變的好看一些啦~~  原作者忘記是誰了,實(shí)在找不到了……萬分抱歉啊~~  效果如下:  復(fù)制代碼  1usingSystem;  2usingSystem.Collections.Generic;  3usingSystem.Linq;  4usingSystem.Web;  5usingSystem.Web.Mvc;  6usingSystem.Web.Routing;  7usingSystem.Text;  8usingSys

2、tem.Web.Mvc.Html;  9namespaceapplication.Helpers  10{  11publicstaticclassPagerExtensions  12{  13/*helper分頁  14*使用方式:<%@ImportNamespace="ExpoShiep.Helpers"%>  15*<%=Html.Pager("page",10,100)%>*/  16///

  17///分頁P(yáng)ager顯示  18///  19///

3、  20///標(biāo)識(shí)當(dāng)前頁碼的QueryStringKey  21///每頁顯示b31.org  22///總數(shù)據(jù)量  23///  24publicstaticstringPager(thisHtmlHelperhtml,stringcurrentPageStr,intpageSize,inttotalCount)  

4、25{  26varqueryString=html.ViewContext.HttpContext.Request.QueryString;  27intcurrentPage=1;//當(dāng)前頁  28vartotalPages=Math.Max((totalCount+pageSize-1)/pageSize,1);//總頁數(shù)  29vardict=newSystem.Web.Routing.RouteValueDictionary(html.ViewContext.RouteData.Values);  30varoutput=newSyste

5、m.Text.StringBuilder();  31if(!string.IsNullOrEmpty(queryString[currentPageStr]))  32{//與相應(yīng)的QueryString綁定  33foreach(stringkeyinqueryString.Keys)  34if(queryString[key]!=null&&!string.IsNullOrEmpty(key))  35dict[key]=queryString[key];  36int.TryParse(queryString[currentPageStr

6、],outcurrentPage);  37}  38else  39{//獲取~/Page/{pagenumber}的頁號(hào)參數(shù)  40int.TryParse(dict[currentPageStr].ToString(),outcurrentPage);  41}  42if(currentPage<=0)  43currentPage=1;  44if(totalPages>1)  45{  46if(currentPage!=1)  47{//處理首頁連接  48dict[currentPageStr]=1;  49output.Appen

7、dFormat("{0}",html.RouteLink("首頁",dict));  50}  51if(currentPage>1)  52{//處理上一頁的連接  53dict[currentPageStr]=currentPage-1;  54output.Append(html.RouteLink("上一頁",dict));  55}  56else  57{  58//output.Append("上一頁");  59dict[currentPageStr]=currentPage;  60output.Append(html.Route

8、Link("上一頁",dict));  61}  62output.Append("");  63intcurrint=5

當(dāng)前文檔最多預(yù)覽五頁,下載文檔查看全文

此文檔下載收益歸作者所有

當(dāng)前文檔最多預(yù)覽五頁,下載文檔查看全文
溫馨提示:
1. 部分包含數(shù)學(xué)公式或PPT動(dòng)畫的文件,查看預(yù)覽時(shí)可能會(huì)顯示錯(cuò)亂或異常,文件下載后無此問題,請放心下載。
2. 本文檔由用戶上傳,版權(quán)歸屬用戶,天天文庫負(fù)責(zé)整理代發(fā)布。如果您對本文檔版權(quán)有爭議請及時(shí)聯(lián)系客服。
3. 下載前請仔細(xì)閱讀文檔內(nèi)容,確認(rèn)文檔內(nèi)容符合您的需求后進(jìn)行下載,若出現(xiàn)內(nèi)容與標(biāo)題不符可向本站投訴處理。
4. 下載文檔時(shí)可能由于網(wǎng)絡(luò)波動(dòng)等原因無法下載或下載錯(cuò)誤,付費(fèi)完成后未能成功下載的用戶請聯(lián)系客服處理。