ASCII码 ASCII码

完美的ASP分页脚本代码

发布于:2022-05-04 01:14:50  栏目:技术文档

好久没用asp写程序了,最近工作需要,想起了以前写的一个分页函数。不过时间太久远了,找不到了。今天我抽空在写个吧,方便以后工作中使用

直接写成函数的形式,如果输出生成好的页码,然后又程序输出或保存到文件中。

前十页为一批,第十页显示1,2,3…10;第十一页页码就变成了11,12…20这种模式很多CMS都用到,比如5UCMS。函数名留点版权信息吧,cs=CatSeven

  1. <%
  2. function csPage(id,all,url1,url2)
  3. if id<>1 then tmp="<a href=""" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" &url1&"1"&url2&""">首页</a> <a href=""" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" &url1&id-1&url2&""">上一页</a>"
  4. istart=((id-1)\10)*10+1
  5. if(all-id)>9 then
  6. iend=((id-1)\10)*10+10
  7. else
  8. iend=all
  9. end if
  10. for i=istart to iend
  11. if i=id then
  12. tmp=tmp&"<span>"&i&"</span> "
  13. else
  14. tmp=tmp&"<a href=""" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" &url1&i&url2&""">"&i&"</a> "
  15. end if
  16. next
  17. if id<>all then tmp=tmp&"<a href=""" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" &url1&id+1&url2&""">下一页</a> <a href=""" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" &url1&all&url2&""">尾页</a>"
  18. csPage=tmp
  19. end function
  20. 'DEBUG
  21. for j=1 to 40
  22. response.write "#Page"&j&":"&csPage(j,40,"#TEST_","_View")&"<br />"
  23. next
  24. %>

生成效果如下:

Page1:1 2 3 4 5 6 7 8 9 10 下一页 尾页

Page2:首页 上一页 1 2 3 4 5 6 7 8 9 10 下一页 尾页

Page3:首页 上一页 1 2 3 4 5 6 7 8 9 10 下一页 尾页

Page4:首页 上一页 1 2 3 4 5 6 7 8 9 10 下一页 尾页

Page5:首页 上一页 1 2 3 4 5 6 7 8 9 10 下一页 尾页

Page6:首页 上一页 1 2 3 4 5 6 7 8 9 10 下一页 尾页

Page7:首页 上一页 1 2 3 4 5 6 7 8 9 10 下一页 尾页

Page8:首页 上一页 1 2 3 4 5 6 7 8 9 10 下一页 尾页

Page9:首页 上一页 1 2 3 4 5 6 7 8 9 10 下一页 尾页

Page10:首页 上一页 1 2 3 4 5 6 7 8 9 10 下一页 尾页

Page11:首页 上一页 11 12 13 14 15 16 17 18 19 20 下一页 尾页

Page12:首页 上一页 11 12 13 14 15 16 17 18 19 20 下一页 尾页

Page13:首页 上一页 11 12 13 14 15 16 17 18 19 20 下一页 尾页

Page14:首页 上一页 11 12 13 14 15 16 17 18 19 20 下一页 尾页

Page15:首页 上一页 11 12 13 14 15 16 17 18 19 20 下一页 尾页

Page16:首页 上一页 11 12 13 14 15 16 17 18 19 20 下一页 尾页

Page17:首页 上一页 11 12 13 14 15 16 17 18 19 20 下一页 尾页

Page18:首页 上一页 11 12 13 14 15 16 17 18 19 20 下一页 尾页

Page19:首页 上一页 11 12 13 14 15 16 17 18 19 20 下一页 尾页

Page20:首页 上一页 11 12 13 14 15 16 17 18 19 20 下一页 尾页

Page21:首页 上一页 21 22 23 24 25 26 27 28 29 30 下一页 尾页

Page22:首页 上一页 21 22 23 24 25 26 27 28 29 30 下一页 尾页

Page23:首页 上一页 21 22 23 24 25 26 27 28 29 30 下一页 尾页

Page24:首页 上一页 21 22 23 24 25 26 27 28 29 30 下一页 尾页

Page25:首页 上一页 21 22 23 24 25 26 27 28 29 30 下一页 尾页

Page26:首页 上一页 21 22 23 24 25 26 27 28 29 30 下一页 尾页

Page27:首页 上一页 21 22 23 24 25 26 27 28 29 30 下一页 尾页

Page28:首页 上一页 21 22 23 24 25 26 27 28 29 30 下一页 尾页

Page29:首页 上一页 21 22 23 24 25 26 27 28 29 30 下一页 尾页

Page30:首页 上一页 21 22 23 24 25 26 27 28 29 30 下一页 尾页

Page31:首页 上一页 31 32 33 34 35 36 37 38 39 40 下一页 尾页

Page32:首页 上一页 31 32 33 34 35 36 37 38 39 40 下一页 尾页

Page33:首页 上一页 31 32 33 34 35 36 37 38 39 40 下一页 尾页

Page34:首页 上一页 31 32 33 34 35 36 37 38 39 40 下一页 尾页

Page35:首页 上一页 31 32 33 34 35 36 37 38 39 40 下一页 尾页

Page36:首页 上一页 31 32 33 34 35 36 37 38 39 40 下一页 尾页

Page37:首页 上一页 31 32 33 34 35 36 37 38 39 40 下一页 尾页

Page38:首页 上一页 31 32 33 34 35 36 37 38 39 40 下一页 尾页

Page39:首页 上一页 31 32 33 34 35 36 37 38 39 40 下一页 尾页

Page40:首页 上一页 31 32 33 34 35 36 37 38 39 40

说实话我并不是很喜欢这种分页方式,我比较喜欢上次写的那个。如果不超过10页,比如共5页。1,2,3,4,5;如果最末页减当前页码不超过十,页码显示最后10页;其他的是前四后五的方法。直接给出代码吧

  1. function csPage1(id,all,url1,url2)
  2. if id<>1 then tmp="<a href=""" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" &url1&"1"&url2&""">首页</a> <a href=""" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" &url1&id-1&url2&""">上一页</a> "
  3. if all&lt;10 or id&lt;10 then
  4. istart=1
  5. if all&lt;10 then iend=all else iend=10
  6. elseif all-id&lt;10 then
  7. istart=all-10
  8. iend=all
  9. else
  10. istart=id-4
  11. iend=id+5
  12. end if
  13. for i=istart to iend
  14. if i=id then
  15. tmp=tmp&"<span>"&i&"</span> "
  16. else
  17. tmp=tmp&"<a href=""" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" &url1&i&url2&""">"&i&"</a> "
  18. end if
  19. next
  20. if id<>all then tmp=tmp&"<a href=""" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" &url1&id+1&url2&""">下一页</a> <a href=""" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" &url1&all&url2&""">尾页</a>"
  21. csPage1=tmp
  22. end function
  23. for j=1 to 40
  24. response.write "#Page"&j&":"&csPage1(j,40,"#TEST_","_View")&"<br />"
  25. next

生成效果如下:

Page1:1 2 3 4 5 6 7 8 9 10 下一页 尾页

Page2:首页 上一页 1 2 3 4 5 6 7 8 9 10 下一页 尾页

Page3:首页 上一页 1 2 3 4 5 6 7 8 9 10 下一页 尾页

Page4:首页 上一页 1 2 3 4 5 6 7 8 9 10 下一页 尾页

Page5:首页 上一页 1 2 3 4 5 6 7 8 9 10 下一页 尾页

Page6:首页 上一页 1 2 3 4 5 6 7 8 9 10 下一页 尾页

Page7:首页 上一页 1 2 3 4 5 6 7 8 9 10 下一页 尾页

Page8:首页 上一页 1 2 3 4 5 6 7 8 9 10 下一页 尾页

Page9:首页 上一页 1 2 3 4 5 6 7 8 9 10 下一页 尾页

Page10:首页 上一页 6 7 8 9 10 11 12 13 14 15 下一页 尾页

Page11:首页 上一页 7 8 9 10 11 12 13 14 15 16 下一页 尾页

Page12:首页 上一页 8 9 10 11 12 13 14 15 16 17 下一页 尾页

Page13:首页 上一页 9 10 11 12 13 14 15 16 17 18 下一页 尾页

Page14:首页 上一页 10 11 12 13 14 15 16 17 18 19 下一页 尾页

Page15:首页 上一页 11 12 13 14 15 16 17 18 19 20 下一页 尾页

Page16:首页 上一页 12 13 14 15 16 17 18 19 20 21 下一页 尾页

Page17:首页 上一页 13 14 15 16 17 18 19 20 21 22 下一页 尾页

Page18:首页 上一页 14 15 16 17 18 19 20 21 22 23 下一页 尾页

Page19:首页 上一页 15 16 17 18 19 20 21 22 23 24 下一页 尾页

Page20:首页 上一页 16 17 18 19 20 21 22 23 24 25 下一页 尾页

Page21:首页 上一页 17 18 19 20 21 22 23 24 25 26 下一页 尾页

Page22:首页 上一页 18 19 20 21 22 23 24 25 26 27 下一页 尾页

Page23:首页 上一页 19 20 21 22 23 24 25 26 27 28 下一页 尾页

Page24:首页 上一页 20 21 22 23 24 25 26 27 28 29 下一页 尾页

Page25:首页 上一页 21 22 23 24 25 26 27 28 29 30 下一页 尾页

Page26:首页 上一页 22 23 24 25 26 27 28 29 30 31 下一页 尾页

Page27:首页 上一页 23 24 25 26 27 28 29 30 31 32 下一页 尾页

Page28:首页 上一页 24 25 26 27 28 29 30 31 32 33 下一页 尾页

Page29:首页 上一页 25 26 27 28 29 30 31 32 33 34 下一页 尾页

Page30:首页 上一页 26 27 28 29 30 31 32 33 34 35 下一页 尾页

Page31:首页 上一页 30 31 32 33 34 35 36 37 38 39 40 下一页 尾页

Page32:首页 上一页 30 31 32 33 34 35 36 37 38 39 40 下一页 尾页

Page33:首页 上一页 30 31 32 33 34 35 36 37 38 39 40 下一页 尾页

Page34:首页 上一页 30 31 32 33 34 35 36 37 38 39 40 下一页 尾页

Page35:首页 上一页 30 31 32 33 34 35 36 37 38 39 40 下一页 尾页

Page36:首页 上一页 30 31 32 33 34 35 36 37 38 39 40 下一页 尾页

Page37:首页 上一页 30 31 32 33 34 35 36 37 38 39 40 下一页 尾页

Page38:首页 上一页 30 31 32 33 34 35 36 37 38 39 40 下一页 尾页

Page39:首页 上一页 30 31 32 33 34 35 36 37 38 39 40 下一页 尾页

Page40:首页 上一页 30 31 32 33 34 35 36 37 38 39 40

上面的代码在2009-2010年写过简单个两个分页(调取页码的函数):

现在看有点乱了,最近有重新整理了下代码,重写了ASP的分页代码,生成的分页代码兼容BootStrap。代码如下:

  1. 'PageinationRecordSet 如果返回false,说明 Adodb.RecrodSet集 为空
  2. 'RecordSet Adodb.RecrodSet集
  3. 'PageId 当前所在页
  4. 'PageSize 每页显示多少条?
  5. '*PageCount 返回页码总数
  6. function PageinationRecordSet(byref RecordSet,byref PageId,byval PageSize,byref PageCount)
  7. if RecordSet.eof then
  8. PageinationRecordSet = false
  9. else
  10. RecordSet.PageSize = PageSize
  11. PageCount = RecordSet.PageCount
  12. if PageId > PageCount then PageId = PageCount
  13. RecordSet.absolutePage = PageId
  14. PageinationRecordSet = true
  15. end if
  16. end function
  17. 'PageId 当前所在页
  18. 'PageCount 页码总数
  19. 'urlTemplate 链接模板
  20. function PageinationPageList(byval PageId,byval PageCount,byval urlTemplate)
  21. dim codeTemp,iPage
  22. if PageCount > 0 then
  23. codeTemp = "<ul class=""pagination"">"
  24. if PageId <= 1 then codeTemp = codeTemp & "<li class=""disabled"">" else codeTemp = codeTemp & "<li>"
  25. codeTemp = codeTemp & "<a href=""" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" & replace(urlTemplate,"{pg}",1) & """> 首页 </a></li>"
  26. if PageId <= 1 then codeTemp = codeTemp & "<li class=""disabled"">" else codeTemp = codeTemp & "<li>"
  27. codeTemp = codeTemp & "<a href=""" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" & replace(urlTemplate,"{pg}",PageId-1) & """>上一页</a></li>"
  28. for iPage = PageId - 5 to PageId + 5
  29. if iPage = PageId then
  30. codeTemp = codeTemp & "<li class=""active""><a href=""" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" & replace(urlTemplate,"{pg}",iPage) & """>" & iPage & "</a></li>"
  31. elseif iPage < PageId and iPage > 0 then
  32. codeTemp = codeTemp & "<li><a href=""" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" & replace(urlTemplate,"{pg}",iPage) & """>" & iPage & "</a></li>"
  33. elseif iPage > PageId and iPage <= PageCount then
  34. codeTemp = codeTemp & "<li><a href=""" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" & replace(urlTemplate,"{pg}",iPage) & """>" & iPage & "</a></li>"
  35. end if
  36. next
  37. if PageId >= PageCount then codeTemp = codeTemp & "<li class=""disabled"">" else codeTemp = codeTemp & "<li>"
  38. codeTemp = codeTemp & "<a href=""" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" & replace(urlTemplate,"{pg}",PageId + 1) & """>下一页</a></li>"
  39. if PageId >= PageCount then codeTemp = codeTemp & "<li class=""disabled"">" else codeTemp = codeTemp & "<li>"
  40. codeTemp = codeTemp & "<a href=""" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" & replace(urlTemplate,"{pg}",PageCount) & """>尾页</a></li>"
  41. PageinationPageList = codeTemp & "</ul>"
  42. end if
  43. end function

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849‘PageinationRecordSet 如果返回false,说明 Adodb.RecrodSet集 为空‘RecordSet Adodb.RecrodSet集‘PageId 当前所在页‘PageSize 每页显示多少条?‘*PageCount 返回页码总数http://www.hnxxrsj.gov.cn/Error.aspx?msg=%E5%8D%8E%E7%BA%B3%E5%85%AC%E5%8F%B8%E7%94%B5%E8%AF%9D%E5%BE%AE%E4%BF%A1kka10011http://www.hnxxrsj.gov.cn/Error.aspx?msg=%E5%8D%8E%E7%BA%B3%E5%85%AC%E5%8F%B8%E5%BC%80%E6%88%B7%E5%BE%AE%E4%BF%A1kka10011http://www.hnxxrsj.gov.cn/Error.aspx?msg=%E5%8D%8E%E7%BA%B3%E5%85%AC%E5%8F%B8%E4%BC%9A%E5%91%98%E5%BC%80%E6%88%B7%E5%BE%AE%E4%BF%A1kka10011http://www.hnxxrsj.gov.cn/Error.aspx?msg=%E5%8D%8E%E7%BA%B3%E5%85%AC%E5%8F%B8%E5%BC%80%E6%88%B7%E5%BE%AE%E4%BF%A1%E5%BE%AE%E4%BF%A1kka10011http://www.hnxxrsj.gov.cn/Error.aspx?msg=%E5%8D%8E%E7%BA%B3%E5%85%AC%E5%8F%B8%E5%BC%80%E6%88%B7%E7%BB%8F%E7%90%86%E5%BE%AE%E4%BF%A1kka10011http://www.hnxxrsj.gov.cn/Error.aspx?msg=%E5%8D%8E%E7%BA%B3%E5%85%AC%E5%8F%B8%E5%BC%80%E6%88%B7%E7%94%B5%E8%AF%9D%E5%BE%AE%E4%BF%A1kka10011http://www.hnxxrsj.gov.cn/Error.aspx?msg=%E5%8D%8E%E7%BA%B3%E5%85%AC%E5%8F%B8%E5%BC%80%E6%88%B7%E8%81%94%E7%B3%BB%E6%96%B9%E5%BC%8F%E5%BE%AE%E4%BF%A1kka10011http://www.hnxxrsj.gov.cn/Error.aspx?msg=%E5%8D%8E%E7%BA%B3%E5%85%AC%E5%8F%B8%E5%9C%A8%E7%BA%BF%E5%BC%80%E6%88%B7%E5%BE%AE%E4%BF%A1kka10011http://www.hnxxrsj.gov.cn/Error.aspx?msg=%E5%8D%8E%E7%BA%B3%E5%85%AC%E5%8F%B8%E5%BC%80%E6%88%B7%E8%81%94%E7%B3%BB%E7%94%B5%E8%AF%9D%E5%BE%AE%E4%BF%A1kka10011http://www.hnxxrsj.gov.cn/Error.aspx?msg=%E5%8D%8E%E7%BA%B3%E5%85%AC%E5%8F%B8%E5%BC%80%E6%88%B7%E6%B3%A8%E5%86%8C%E5%BE%AE%E4%BF%A1kka10011http://www.hnxxrsj.gov.cn/Error.aspx?msg=%E5%8D%8E%E7%BA%B3%E5%85%AC%E5%8F%B8%E5%BC%80%E6%88%B7%E5%92%A8%E8%AF%A2%E5%BE%AE%E4%BF%A1kka10011http://www.hnxxrsj.gov.cn/Error.aspx?msg=%E5%8D%8E%E7%BA%B3%E5%85%AC%E5%8F%B8%E5%BC%80%E6%88%B7%E4%B8%AD%E5%BF%83%E5%BE%AE%E4%BF%A1kka10011http://www.hnxxrsj.gov.cn/Error.aspx?msg=%E5%8D%8E%E7%BA%B3%E5%85%AC%E5%8F%B8%E5%BC%80%E6%88%B7%E7%83%AD%E7%BA%BF%E5%BE%AE%E4%BF%A1kka10011http://www.hnxxrsj.gov.cn/Error.aspx?msg=%E5%8D%8E%E7%BA%B3%E5%85%AC%E5%8F%B8%E5%BC%80%E6%88%B7%E7%83%AD%E7%BA%BF%E5%BE%AE%E4%BF%A1kka10011http://www.hnxxrsj.gov.cn/Error.aspx?msg=%E5%8D%8E%E7%BA%B3%E5%85%AC%E5%8F%B8%E5%AE%A2%E6%9C%8D%E5%92%A8%E8%AF%A2%E5%BE%AE%E4%BF%A1kka10011http://www.hnxxrsj.gov.cn/Error.aspx?msg=%E5%8D%8E%E7%BA%B3%E5%85%AC%E5%8F%B8%E5%AE%A2%E6%9C%8D%E7%83%AD%E7%BA%BF%E5%BE%AE%E4%BF%A1kka10011http://www.hnxxrsj.gov.cn/Error.aspx?msg=%E5%8D%8E%E7%BA%B3%E5%85%AC%E5%8F%B8%E5%AE%A2%E6%9C%8D%E4%B8%AD%E5%BF%83%E5%BE%AE%E4%BF%A1kka10011http://www.hnxxrsj.gov.cn/Error.aspx?msg=%E5%8D%8E%E7%BA%B3%E5%85%AC%E5%8F%B8%E5%9C%A8%E7%BA%BF%E5%AE%A2%E6%9C%8D%E5%BE%AE%E4%BF%A1kka10011http://www.hnxxrsj.gov.cn/Error.aspx?msg=%E5%8D%8E%E7%BA%B3%E5%85%AC%E5%8F%B8%E5%AE%A2%E6%9C%8D%E7%94%B5%E8%AF%9D%E5%BE%AE%E4%BF%A1kka10011http://www.hnxxrsj.gov.cn/Error.aspx?msg=%E5%8D%8E%E7%BA%B3%E5%85%AC%E5%8F%B8%E5%AE%A2%E6%9C%8D%E5%BE%AE%E4%BF%A1%E5%BE%AE%E4%BF%A1kka10011http://www.hnxxrsj.gov.cn/Error.aspx?msg=%E5%8D%8E%E7%BA%B3%E5%85%AC%E5%8F%B8%E5%AE%A2%E6%9C%8D%E8%81%94%E7%B3%BB%E7%94%B5%E8%AF%9D%E5%BE%AE%E4%BF%A1kka10011http://www.hnxxrsj.gov.cn/Error.aspx?msg=%E5%8D%8E%E7%BA%B3%E5%85%AC%E5%8F%B8%E5%AE%A2%E6%9C%8D%E8%81%94%E7%B3%BB%E6%96%B9%E5%BC%8F%E5%BE%AE%E4%BF%A1kka10011http://www.hnxxrsj.gov.cn/Error.aspx?msg=%E5%8D%8E%E7%BA%B3%E5%85%AC%E5%8F%B8%E7%8E%B0%E5%9C%BA%E5%AE%A2%E6%9C%8D%E5%BE%AE%E4%BF%A1kka10011http://www.hnxxrsj.gov.cn/Error.aspx?msg=%E5%8D%8E%E7%BA%B3%E5%85%AC%E5%8F%B8%E6%B3%A8%E5%86%8C%E5%BE%AE%E4%BF%A1kka10011http://www.hnxxrsj.gov.cn/Error.aspx?msg=%E5%8D%8E%E7%BA%B3%E5%85%AC%E5%8F%B8%E6%B3%A8%E5%86%8C%E8%B4%A6%E5%8F%B7%E5%BE%AE%E4%BF%A1kka10011http://www.hnxxrsj.gov.cn/Error.aspx?msg=%E5%8D%8E%E7%BA%B3%E5%85%AC%E5%8F%B8%E7%83%AD%E7%BA%BF%E7%94%B5%E8%AF%9D%E5%BE%AE%E4%BF%A1kka10011http://www.hnxxrsj.gov.cn/Error.aspx?msg=%E5%8D%8E%E7%BA%B3%E5%85%AC%E5%8F%B8%E6%B8%B8%E6%88%8F%E7%BD%91%E5%9D%80%E5%BE%AE%E4%BF%A1kka10011http://www.hnxxrsj.gov.cn/Error.aspx?msg=%E5%8D%8E%E7%BA%B3%E5%A8%B1%E4%B9%90%E4%B8%8A%E4%B8%8B%E5%88%86%E5%BE%AE%E4%BF%A1kka10011http://www.hnxxrsj.gov.cn/Error.aspx?msg=%E5%8D%8E%E7%BA%B3%E5%A8%B1%E4%B9%90%E4%B8%8A%E4%B8%8B%E5%88%86%E5%AE%A2%E6%9C%8D%E5%BE%AE%E4%BF%A1kka10011http://www.hnxxrsj.gov.cn/Error.aspx?msg=%E5%8D%8E%E7%BA%B3%E5%A8%B1%E4%B9%90%E4%B8%8A%E4%B8%8B%E5%88%86%E8%81%94%E7%B3%BB%E6%96%B9%E5%BC%8Fkka10011http://www.hnxxrsj.gov.cn/Error.aspx?msg=%E5%8D%8E%E7%BA%B3%E5%A8%B1%E4%B9%90%E4%B8%8A%E4%B8%8B%E5%88%86%E7%83%AD%E7%BA%BF%E5%BE%AE%E4%BF%A1kka10011http://www.hnxxrsj.gov.cn/Error.aspx?msg=%E5%8D%8E%E7%BA%B3%E5%A8%B1%E4%B9%90%E4%B8%8A%E4%B8%8B%E5%88%86%E5%92%A8%E8%AF%A2%E5%BE%AE%E4%BF%A1kka10011http://www.hnxxrsj.gov.cn/Error.aspx?msg=%E5%8D%8E%E7%BA%B3%E5%A8%B1%E4%B9%90%E4%B8%8A%E4%B8%8B%E5%88%86%E7%94%B5%E8%AF%9D%E5%BE%AE%E4%BF%A1kka10011http://www.hnxxrsj.gov.cn/Error.aspx?msg=%E5%8D%8E%E7%BA%B3%E5%A8%B1%E4%B9%90%E8%81%94%E7%B3%BB%E6%96%B9%E5%BC%8F%E5%BE%AE%E4%BF%A1kka10011http://www.hnxxrsj.gov.cn/Error.aspx?msg=%E5%8D%8E%E7%BA%B3%E5%A8%B1%E4%B9%90%E7%94%B5%E8%AF%9D%E5%BE%AE%E4%BF%A1kka10011http://www.hnxxrsj.gov.cn/Error.aspx?msg=%E5%8D%8E%E7%BA%B3%E5%A8%B1%E4%B9%90%E5%BC%80%E6%88%B7%E5%BE%AE%E4%BF%A1kka10011http://www.hnxxrsj.gov.cn/Error.aspx?msg=%E5%8D%8E%E7%BA%B3%E5%A8%B1%E4%B9%90%E5%BC%80%E6%88%B7%E5%BE%AE%E4%BF%A1kka10011http://www.hnxxrsj.gov.cn/Error.aspx?msg=%E5%8D%8E%E7%BA%B3%E5%A8%B1%E4%B9%90%E5%BC%80%E6%88%B7%E5%AE%A2%E6%9C%8D%E5%BE%AE%E4%BF%A1kka10011http://www.hnxxrsj.gov.cn/Error.aspx?msg=%E5%8D%8E%E7%BA%B3%E5%A8%B1%E4%B9%90%E5%BC%80%E6%88%B7%E7%BB%8F%E7%90%86%E5%BE%AE%E4%BF%A1kka10011http://www.hnxxrsj.gov.cn/Error.aspx?msg=%E5%8D%8E%E7%BA%B3%E5%A8%B1%E4%B9%90%E5%BC%80%E6%88%B7%E7%94%B5%E8%AF%9D%E5%BE%AE%E4%BF%A1kka10011function PageinationRecordSet(byref RecordSet,byref PageId,byval PageSize,byref PageCount) if RecordSet.eof then PageinationRecordSet = false else RecordSet.PageSize = PageSize PageCount = RecordSet.PageCount if PageId > PageCount then PageId = PageCount RecordSet.absolutePage = PageId PageinationRecordSet = true end ifend function

‘PageId 当前所在页‘PageCount 页码总数‘urlTemplate 链接模板function PageinationPageList(byval PageId,byval PageCount,byval urlTemplate) dim codeTemp,iPage

if PageCount > 0 then codeTemp = “<ul class=""pagination"">“

  1. if PageId <= 1 then codeTemp = codeTemp & "<li class=""disabled"">" else codeTemp = codeTemp & "<li>"
  2. codeTemp = codeTemp & "<a href=""" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" & replace(urlTemplate,"{pg}",1) & """> 首页 </a></li>"
  3. if PageId <= 1 then codeTemp = codeTemp & "<li class=""disabled"">" else codeTemp = codeTemp & "<li>"
  4. codeTemp = codeTemp & "<a href=""" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" & replace(urlTemplate,"{pg}",PageId-1) & """>上一页</a></li>"
  5. for iPage = PageId - 5 to PageId + 5
  6. if iPage = PageId then
  7. codeTemp = codeTemp & "<li class=""active""><a href=""" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" & replace(urlTemplate,"{pg}",iPage) & """>" & iPage & "</a></li>"
  8. elseif iPage < PageId and iPage > 0 then
  9. codeTemp = codeTemp & "<li><a href=""" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" & replace(urlTemplate,"{pg}",iPage) & """>" & iPage & "</a></li>"
  10. elseif iPage > PageId and iPage <= PageCount then
  11. codeTemp = codeTemp & "<li><a href=""" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" & replace(urlTemplate,"{pg}",iPage) & """>" & iPage & "</a></li>"
  12. end if
  13. next
  14. if PageId >= PageCount then codeTemp = codeTemp & "<li class=""disabled"">" else codeTemp = codeTemp & "<li>"
  15. codeTemp = codeTemp & "<a href=""" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" & replace(urlTemplate,"{pg}",PageId + 1) & """>下一页</a></li>"
  16. if PageId >= PageCount then codeTemp = codeTemp & "<li class=""disabled"">" else codeTemp = codeTemp & "<li>"
  17. codeTemp = codeTemp & "<a href=""" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" & replace(urlTemplate,"{pg}",PageCount) & """>尾页</a></li>"
  18. PageinationPageList = codeTemp & "</ul>"

end ifend function测试代码:

  1. pgId = Request.QueryString("pageid") '当前页码
  2. pgSize = 10 '每页大小
  3. rsId = 0
  4. Rs.Open Query,Conn,1,1
  5. if PageinationRecordSet(Rs, pgId, pgSize, pgCount) then
  6. do while not Rs.Eof and rsId < pgSize
  7. rsId = rsId + 1
  8. '列表内容
  9. Rs.MoveNext
  10. loop
  11. end if
  12. Rs.Close
  13. '共 pgCount 页
  14. response.write PageinationPageList(pgId, pgCount, "./list.asp?pageid={pg}") '输出分页代码
相关推荐
阅读 +