Asp用于分页的两个函数

2016-01-29 18:58 5 1 收藏

Asp用于分页的两个函数,Asp用于分页的两个函数

【 tulaoshi.com - ASP 】

 

(原创 vince6799)
在asp代码中分页是有点麻烦的事情,个人在在代码编写过程中把分页代码写成了两个函数,虽然在功能上不是很完善,但对于一般的应用应该是满足的了。

(本文来源于图老师网站,更多请访问https://www.tulaoshi.com/asp/)

<%
'分页函数分为两个函数
'CalcPage(totalrec,msg_per_page,currentpage,n,rowcount,PageRs) 分页计算函数
'PageList(ListType,url,querry,Separator,ListLink) 分页列表函数

'分页计算函数
'totalrec 记录集总数
'msg_per_page 每页显示的记录数,在调用CalcPage时需提前对该变量赋值
'currentpage 当前页变量,在调用CalcPage时需提前对该变量赋值
'n 总页数 
'rowcount 设置每一页的数据记录数
'PageRs 记录集对象
sub CalcPage(totalrec,msg_per_page,currentpage,n,rowcount,PageRs)
 n=0 '设置无记录时页数为0
 if currentpage="" then currentpage=0
 'PageRs.EOF and PageRs.bof  无记录
 'Not PageRs.EOF Or Not PageRs.BOF 有记录
 if Not PageRs.EOF Or Not PageRs.BOF then
  totalrec=PageRs.recordcount
  PageRs.pagesize=msg_per_page
  if totalrec mod msg_per_page = 0 then '计算总页数,recordcount:数据的总记录数
   n = totalrecmsg_per_page 'n:总页数
  else
   n = totalrecmsg_per_page+1
  end if
  if not isnumeric(currentpage) or currentpage="" then currentpage=1
  If currentpage < "" then
   currentpage = cint(currentpage)
  end if
  if currentpage < 1 then
   currentpage = 1
  end if
  if currentpage*msg_per_page totalrec and not((currentpage-1)*msg_per_page < totalrec) then
   currentPage=1
  end if
  PageRs.absolutepage = currentpage 'absolutepage:设置指针指向某页开头
  rowcount = PageRs.pagesize            'pagesize:设置每一页的数据记录数
 end if
end sub
%
<%
'分页列表函数
'url 跳转的地址
'querry ?后的参数
'Separator 分隔符
'ListType 分页类型
'类型:0 "第一页 | 前一页 | | 最后页"
'类型:1 "1 | 2 | 3 | 4 | ..........| "
'类型:2 "第一页 | 前十页 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 后十页 | 最后页"
'ListLink 链接使用的样式

(本文来源于图老师网站,更多请访问https://www.tulaoshi.com/asp/)

sub PageList(ListType,url,querry,Separator,ListLink)
 if Separator="" then Separator="|"
 if ListType="" then ListType="0"
 select case ListType
  case "0"
   response.write"第"&currentpage&"/"&n&"页&nbsp;&nbsp;"
   response.write"共"&totalrec&"条信息&nbsp;&nbsp;"
   if currentpage <= 1 then
   response.write"第一页&nbsp;"&Separator&"&nbsp;"
   response.write"前一页&nbsp;"&Separator&"&nbsp;"
   else
   response.write"<a href="""&url&"?page=1&"&querry&""" class="""&ListLink&"""第一页</a&nbsp;"&Separator&"&nbsp;"
   response.write"<a href="""&url&"?page="&currentpage-1&"&"&querry&"""  class="""&ListLink&"""前一页</a&nbsp;"&Separator&"&nbsp;"
   end if
   if currentpage = n then
   response.write"&nbsp;"&Separator&"&nbsp;"
   response.write"最后页&nbsp;"
   else
   response.write"<a href="""&url&"?page="&currentpage+1&"&"&querry&"""  class="""&ListLink&"""</a&nbsp;"&Separator&"&nbsp;"
   response.write"<a href="""&url&"?page="&n&"&"&querry&""" class="""&ListLink&"""最后页</a&nbsp;"
   end if
  case "1"
   if currentpage < n then
    response.write"<a href="""&url&"?page="&currentpage+1&"&"&querry&""" class="""&ListLink&"""</a&nbsp;"   
 &nbs

来源:https://www.tulaoshi.com/n/20160129/1507972.html

延伸阅读
标签: Web开发
function request(paras){ //获取 url 的参数值,不区分大小写,如无此参数,返回空字符串. var url = location.href; var paraString = url.substring(url.indexOf("?")+1,url.length).split("&"); var paraObj = {} for (i=0; j=paraString[i]; i++){ p...
标签: Web开发
代码如下: Function DRexPage(Str) Dim RegEx If IsNull(Str) Or Str="" Then Exit Function Set RegEx=New RegExp RegEx.IgnoreCase=True RegEx.pattern="(\&)?page=(\d)+" DRexPage=regEx.replace(Str,"") '(Str,"$1") Set RegEx=Nothing End Function
埋头苦干一天终于搞定!一个用C#写的windows应用程序,作用嘛,就是对asp程序已知的20种漏洞进行扫描,显示源程序。在这个应用程序中用到两种获得http页面的方法,一种是直接用httpwebrequest类,而另一种是同服务器通过tcp/ip建立socket连接,直接查询端口80 , 为此我写了以下两个函数,第一个比较简单,参数只有一个,就是要求的url , 另外一...
第一个: ------------------------------------------------------ 代码如下: #include stdio.h #include string.h void tell_me(int f(const char *, const char *)); int main(void) {    tell_me(strcmp);    tell_me(main);    return 0; } void tell_me(int f(const char *, const char *)) {  &n...
标签: PHP
  //在PHP中处理日期非常不方便,比如求两个日期之间相差的月份?该怎么办呢?  //文件名:date.inc.php3  //在使用这两个函数前,要先将日期或日期时间转换成timestamp类型。  //如:  //$today=mktime(0,0,0,date("m"),date("d"),date("Y"));  /****模拟sqlserver中的dateadd...

经验教程

14

收藏

68
微博分享 QQ分享 QQ空间 手机页面 收藏网站 回到头部