程序博客网 > 女人淘宝买包包
来源:互联网 发布:女人淘宝买包包 编辑:程序博客网 时间:2024/05/21 07:47
public string FullModePager() { //int allpage = 0; int next = 0; //int pre = 0; int startcount = 0; int endcount = 0; string pagestr = "<div id=/"pagebar/" class=/"pagination/"><ul>"; if (this.pageIndex < 1) { this.pageIndex = 1; } //计算总页数 if (this.pageSize != 0) { this.totalPageCount = (this.totalRecordCount / this.pageSize); this.totalPageCount = ((this.totalRecordCount % this.pageSize) != 0 ? this.totalPageCount + 1 : this.totalPageCount); this.totalPageCount = (this.totalPageCount == 0 ? 1 : this.totalPageCount); } next = this.pageIndex + 1; this.pageSize = this.pageIndex - 1; startcount = (this.pageIndex + 5) > this.totalPageCount ? this.totalPageCount - 9 : this.pageIndex - 4;//中间页起始序号 //中间页终止序号 endcount = this.pageIndex < 5 ? 10 : this.pageIndex + 5; if (startcount < 1) { startcount = 1; } //为了避免输出的时候产生负数,设置如果小于1就从序号1开始 if (this.totalPageCount < endcount) { endcount = this.totalPageCount; }//页码+5的可能性就会产生最终输出序号大于总页码,那么就要将其控制在页码数之内 pagestr += this.pageIndex > 1 ? "<li><a href="/" mce_href="/""" + string.Format(this.FormatUrl, 1) + "/">1..</a></li><li><a href="/" mce_href="/""" + string.Format(this.FormatUrl, this.pageSize) + "/">‹‹</a></li>" : string.Empty;//"<li class=/"disablepage/">首页</li><li class=/"disablepage/">‹‹</li>"; //中间页处理,这个增加时间复杂度,减小空间复杂度 for (int i = startcount; i <= endcount; i++) { pagestr += this.pageIndex == i ? "<li class=/"current/">" + i + "</li>" : "<li><a href="/" mce_href="/""" + string.Format(this.FormatUrl, i) + "/">" + i + "</a></li>"; } pagestr += this.pageIndex != this.totalPageCount ? "<li><a href="/" mce_href="/""" + string.Format(this.FormatUrl, next) + "/">››</a></li><li><a href="/" mce_href="/""" + string.Format(this.FormatUrl, this.totalPageCount) + "/">.." + this.totalPageCount.ToString() + "</a></li>" : string.Empty;// "<li class=/"disablepage/">››</li><li class=/"disablepage/">末页</li>"; pagestr += "<li class=/"info/">" + this.pageIndex.ToString() + " / " + this.totalPageCount + " | " + this.totalRecordCount.ToString() + " total</li>"; pagestr += string.Format("<li class=/"goto/"><input type=/"text/" title=/"输入数字,回车跳转/" size=/"3/" onkeydown=/"if (13==event.keyCode) document.location.href='{0}'+this.value/" value=/"{1}/" /></li></ul></div>", string.Format(this.FormatUrl, ""), this.pageIndex); return pagestr; }