好久没用asp写程序了,最近工作需要,想起了以前写的一个分页函数。不过时间太久远了,找不到了。今天我抽空在写个吧,方便以后工作中使用
直接写成函数的形式,如果输出生成好的页码,然后又程序输出或保存到文件中。
前十页为一批,第十页显示1,2,3…10;第十一页页码就变成了11,12…20这种模式很多CMS都用到,比如5UCMS。函数名留点版权信息吧,cs=CatSeven
<%function csPage(id,all,url1,url2)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>"istart=((id-1)\10)*10+1if(all-id)>9 theniend=((id-1)\10)*10+10elseiend=allend iffor i=istart to iendif i=id thentmp=tmp&"<span>"&i&"</span> "elsetmp=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> "end ifnextif 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>"csPage=tmpend function'DEBUGfor j=1 to 40response.write "#Page"&j&":"&csPage(j,40,"#TEST_","_View")&"<br />"next%>
生成效果如下:
说实话我并不是很喜欢这种分页方式,我比较喜欢上次写的那个。如果不超过10页,比如共5页。1,2,3,4,5;如果最末页减当前页码不超过十,页码显示最后10页;其他的是前四后五的方法。直接给出代码吧
function csPage1(id,all,url1,url2)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> "if all<10 or id<10 thenistart=1if all<10 then iend=all else iend=10elseif all-id<10 thenistart=all-10iend=allelseistart=id-4iend=id+5end iffor i=istart to iendif i=id thentmp=tmp&"<span>"&i&"</span> "elsetmp=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> "end ifnextif 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>"csPage1=tmpend functionfor j=1 to 40response.write "#Page"&j&":"&csPage1(j,40,"#TEST_","_View")&"<br />"next
生成效果如下:
上面的代码在2009-2010年写过简单个两个分页(调取页码的函数):
现在看有点乱了,最近有重新整理了下代码,重写了ASP的分页代码,生成的分页代码兼容BootStrap。代码如下:
'PageinationRecordSet 如果返回false,说明 Adodb.RecrodSet集 为空'RecordSet Adodb.RecrodSet集'PageId 当前所在页'PageSize 每页显示多少条?'*PageCount 返回页码总数function PageinationRecordSet(byref RecordSet,byref PageId,byval PageSize,byref PageCount)if RecordSet.eof thenPageinationRecordSet = falseelseRecordSet.PageSize = PageSizePageCount = RecordSet.PageCountif PageId > PageCount then PageId = PageCountRecordSet.absolutePage = PageIdPageinationRecordSet = trueend ifend function'PageId 当前所在页'PageCount 页码总数'urlTemplate 链接模板function PageinationPageList(byval PageId,byval PageCount,byval urlTemplate)dim codeTemp,iPageif PageCount > 0 thencodeTemp = "<ul class=""pagination"">"if PageId <= 1 then codeTemp = codeTemp & "<li class=""disabled"">" else codeTemp = codeTemp & "<li>"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>"if PageId <= 1 then codeTemp = codeTemp & "<li class=""disabled"">" else codeTemp = codeTemp & "<li>"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>"for iPage = PageId - 5 to PageId + 5if iPage = PageId thencodeTemp = 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>"elseif iPage < PageId and iPage > 0 thencodeTemp = 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>"elseif iPage > PageId and iPage <= PageCount thencodeTemp = 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>"end ifnextif PageId >= PageCount then codeTemp = codeTemp & "<li class=""disabled"">" else codeTemp = codeTemp & "<li>"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>"if PageId >= PageCount then codeTemp = codeTemp & "<li class=""disabled"">" else codeTemp = codeTemp & "<li>"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>"PageinationPageList = codeTemp & "</ul>"end ifend 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"">“
if PageId <= 1 then codeTemp = codeTemp & "<li class=""disabled"">" else codeTemp = codeTemp & "<li>"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>"if PageId <= 1 then codeTemp = codeTemp & "<li class=""disabled"">" else codeTemp = codeTemp & "<li>"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>"for iPage = PageId - 5 to PageId + 5if iPage = PageId thencodeTemp = 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>"elseif iPage < PageId and iPage > 0 thencodeTemp = 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>"elseif iPage > PageId and iPage <= PageCount thencodeTemp = 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>"end ifnextif PageId >= PageCount then codeTemp = codeTemp & "<li class=""disabled"">" else codeTemp = codeTemp & "<li>"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>"if PageId >= PageCount then codeTemp = codeTemp & "<li class=""disabled"">" else codeTemp = codeTemp & "<li>"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>"PageinationPageList = codeTemp & "</ul>"
end ifend function测试代码:
pgId = Request.QueryString("pageid") '当前页码pgSize = 10 '每页大小rsId = 0Rs.Open Query,Conn,1,1if PageinationRecordSet(Rs, pgId, pgSize, pgCount) thendo while not Rs.Eof and rsId < pgSizersId = rsId + 1'列表内容Rs.MoveNextloopend ifRs.Close'共 pgCount 页response.write PageinationPageList(pgId, pgCount, "./list.asp?pageid={pg}") '输出分页代码
相关推荐
© 2020 asciim码
人生就是一场修行