博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
asp.net文章内容分页方法
阅读量:7112 次
发布时间:2019-06-28

本文共 3556 字,大约阅读时间需要 11 分钟。

#region Html内容分页处理函数        ///         /// Html内容分页处理函数         ///         /// 要分页的内容        /// 分隔字符串        /// 页面索引参数名        /// 链接匹配模式        /// 是否追加第一页和最后一页        /// 
public static string CreateContentPager(ref string strBody, string strSplitString, string pageIndexName, string patter, bool isAppendHeadEnd) { string[] strBodyArray = strBody.Split(new string[] { strSplitString }, StringSplitOptions.None); //分页内容 StringBuilder strHtmlPager = new StringBuilder(); int currentPageIndex = 1; //当前页页码 int pageCount = strBodyArray.Length;//总页数 if (!string.IsNullOrEmpty(HttpContext.Current.Request[pageIndexName])) { currentPageIndex = CommonFunction.getInteger(HttpContext.Current.Request[pageIndexName]); } //无需分页 if (pageCount == 1) { return null; } //开始分页处理 if (isAppendHeadEnd) { if (currentPageIndex == 1) { strHtmlPager.AppendLine(); strHtmlPager.Append("[第一页]"); } else { strHtmlPager.AppendLine(); strHtmlPager.Append(patter.Replace("{0}", 1.ToString()).Replace("{1}", "第一页")); } } //页头 if (currentPageIndex > 1) { //显示上一页 strHtmlPager.AppendLine(); strHtmlPager.Append(patter.Replace("{0}", (currentPageIndex - 1).ToString()).Replace("{1}", "上一页")); } else { if (currentPageIndex == 1) { strHtmlPager.AppendLine(); strHtmlPager.Append("[上一页]"); } } //开始分页 for (int i = 1; i <= pageCount; i++) { //如果 当前页索引=页码的话,执行操作标示当前页码 if (i == currentPageIndex) { strHtmlPager.AppendLine(); strHtmlPager.AppendFormat("[{0}]", i); } else { strHtmlPager.AppendLine(); strHtmlPager.AppendFormat(patter.Replace("{0}", i.ToString()).Replace("{1}", i.ToString())); } } //页尾 if (currentPageIndex + 1 > pageCount) { strHtmlPager.AppendLine(); strHtmlPager.Append("[下一页]"); } else { strHtmlPager.AppendLine(); strHtmlPager.Append(patter.Replace("{0}", (currentPageIndex + 1).ToString()).Replace("{1}", "下一页")); } if (isAppendHeadEnd) { if (currentPageIndex == pageCount) { strHtmlPager.AppendLine(); strHtmlPager.Append("[已经是最后一页]"); } else { strHtmlPager.AppendLine(); strHtmlPager.Append(patter.Replace("{0}", pageCount.ToString()).Replace("{1}", "最后一页")); } } strBody = strBodyArray[currentPageIndex - 1]; return strHtmlPager.ToString(); } #endregion

 

转载于:https://www.cnblogs.com/thinkingthigh/archive/2013/06/08/3126662.html

你可能感兴趣的文章
Oracle---使用PL/SQL Developer连接Oracle12C(64位)版本
查看>>
④云上场景:浙江网商银行,三层金融云实践
查看>>
mongoDB VS PostgreSQL dml performance use python (pymongo & py-postgresql)
查看>>
Github上的star和fork是什么
查看>>
说说 ParcelJS
查看>>
2018.03.08、View的事件分发机制笔记
查看>>
基于ubuntu16.04快速构建Hyperledger Fabric网络
查看>>
前端异常处理最佳实践
查看>>
# 基于VirtualApk的Android手游SDK插件化架构(一)
查看>>
jvm类加载机制
查看>>
让更多人知道你——给开源库提交 pr
查看>>
使用ipmi调节r410的风扇转速
查看>>
Spring Cloud超简单十分钟入门实例
查看>>
Linux环境Apache2.4+mysql5.7+php5.6快速安装mysql
查看>>
MySql 日常指导,及大表优化思路
查看>>
设计模式之 - 单例模式
查看>>
用 Python 脚本,监听附近网络 Wi-Fi 设备,通过邮件和微信进行消息推送
查看>>
巅峰之证!首位阿里云ACE认证专家产生
查看>>
Spring Cloud Alibaba Sentinel对RestTemplate的支持
查看>>
canvas
查看>>