国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 網站 > 建站經驗 > 正文

簡單好用的ASP_.NET分頁類(支持AJAX、自定義文字)

2019-11-02 15:41:44
字體:
來源:轉載
供稿:網友

   這篇文章主要介紹了簡單好用的ASP.NET分頁類(支持AJAX、自定義文字),本文直接給出實現代碼和使用方法,需要的朋友可以參考下

  在做網站沒用 JS UI控件時 很實用

  用法:

  ?

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 var ps=new PageString();   /*可選參數*/   ps.SetIsEnglish = true;// 是否是英文 (默認:false) ps.SetIsShowText = true;//是否顯示分頁文字 (默認:true) //ps.TextFormat="" (默認值:《span class="pagetext"》《strong》總共《/strong》:{0} 條 《strong》當前《/strong》:{1}/{2}《/span》) //ps.SetPageIndexName Request["pageIndex"](默認值:"pageIndex") ps.SetIsAjax = false;// (默認值:"false")   /*函數參數*/ int total = 10000; int pageSize = 10; int pageIndex = Convert.ToInt32(Request["pageIndex"]);   var page = ps.ToString(total, pageSize, pageIndex, "/UI/PageStringTest.aspx?");   //獲取 page html 輸出 Response.Write(page);

  效果:

  代碼:

  ?

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Text.RegularExpressions;   namespace SyntacticSugar { /// <summary> /// ** 描述:分頁類 /// ** 創始時間:2015-5-29 /// ** 修改時間:- /// ** 作者:sunkaixuan public class PageString { /// <summary> /// 是否是英文 (默認:false) /// </summary> public bool SetIsEnglish { get; set; } /// <summary> /// 是否顯示分頁文字(默認:true) /// </summary> public bool SetIsShowText { get; set; } /// <summary> /// 樣式 (默認:"pagination") /// </summary> public string SetClassName { get; set; } /// <summary> /// 分頁參數名 (默認:"pageIndex") /// </summary> public string SetPageIndexName { get; set; } /// <summary> /// 是否是異步 同步 href='' 異步 onclick=ajaxPage() (默認:false) /// </summary> public bool SetIsAjax { get; set; }   /// <summary> /// 自定義文字 /// string.Format("{0}{1}{2}","總記錄數","當前頁數","總頁數") /// 默認值:《span class="pagetext"》《strong》總共《/strong》:{0} 條 《strong》當前《/strong》:{1}/{2}《/span》 /// </summary> public string SetTextFormat { get; set; }   public PageString() { SetIsEnglish = false; SetIsShowText = true; SetTextFormat = "<span class="pagetext"><strong>總共</strong>:{0} 條 <strong>當前</strong>:{1}/{2}</span> "; SetClassName = "pagination"; SetPageIndexName = "pageIndex"; SetIsAjax = false; }   /*免費的樣式 .pagination .click {cursor:pointer} .pagination a{text-decoration: none;border: 1px solid #AAE;color: #15B;font-size: 13px;border-radius: 2px;} .pagination span{ color:#666;font-size:13px;display: inline-block;border: 1px solid #ccc;padding: 0.2em 0.6em;} .pagination span.pagetext{ border:none} .pagination a:hover{background: #26B;color: #fff;} .pagination a{display: inline-block;padding: 0.2em 0.6em;} .pagination .page_current{background: #26B;color: #fff;border: 1px solid #AAE;margin-right: 5px;} .pagination{margin-top: 20px;} .pagination .current.prev, .pagination .current.next{color: #999;border-color: #999;background: #fff;} * */   /// <summary> /// 分頁算法<一>共20頁 首頁 上一頁 1 2 3 4 5 6 7 8 9 10 下一頁 末頁 /// </summary> /// <param name="total">總記錄數</param> /// <param name="pageSize">每頁記錄數</param> /// <param name="pageIndex">當前頁數</param> /// <param name="query_string">Url參數</param> /// <returns></returns> public string ToString(int total, int pageSize, int pageIndex, string query_string) {   int allpage = 0; int next = 0; int pre = 0; int startcount = 0; int endcount = 0; StringBuilder pagestr = new Stri
發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 勐海县| 新野县| 乡城县| 镇赉县| 敦煌市| 容城县| 屏东县| 康保县| 临海市| 谷城县| 综艺| 交城县| 虞城县| 辰溪县| 钟祥市| 太仆寺旗| 普兰店市| 石柱| 信阳市| 余庆县| 崇阳县| 罗定市| 成安县| 涟源市| 怀集县| 宜宾县| 榆社县| 沙河市| 页游| 永吉县| 依安县| 凭祥市| 广饶县| 陆丰市| 克什克腾旗| 工布江达县| 大安市| 丰顺县| 德兴市| 民勤县| 门源|