加入收藏 | 设为首页 | 会员中心 | 我要投稿 银川站长网 (https://www.0951zz.com/)- 云通信、基础存储、云上网络、机器学习、视觉智能!
当前位置: 首页 > 站长学院 > Asp教程 > 正文

ASP 数字分页成效代码

发布时间:2023-04-25 12:43:38 所属栏目:Asp教程 来源:
导读:最近网站改版正好发现原来的分页不带数字的,只有首页 上页 下页 末页 然后是select的跳转,都是以前比较流行的,而现在比较流行的是数字分页在中间,正好研究并分享下,需要的朋友可以参考下国外的核心代码:代码如

最近网站改版正好发现原来的分页不带数字的,只有首页 上页 下页 末页 然后是select的跳转,都是以前比较流行的,而现在比较流行的是数字分页在中间,正好研究并分享下,需要的朋友可以参考下

国外的核心代码:

代码如下:

<%

 'digg style pagination script in asp.. written by Moazam... http://www.moazam.com/2007/03/30/asp-digg-style-pagination-script/

 function getPaginationString(page, totalitems, limit, adjacents, targetpage) 

  'defaults

  if not isnumeric(adjacents) then adjacents = 1 end if

  if not isnumeric(limit) then limit = 15 end if

  if not isnumeric(page) then page = 1 end if

  if targetpage = "" then targetpage = "/" end if

  margin = ""

  padding=""

  'other vars

  prev = page - 1         'previous page is page - 1

  nextPage = page + 1         'nextPage page is page + 1

  lastpage = Ceil(totalitems , limit)    'lastpage is = total items / items per page, rounded up.

  lpm1 = lastpage - 1        'last page minus 1

  ' Now we apply our rules and draw the pagination object.

  ' We're actually saving the code to a variable in case we want to draw it more than once.

  pagination = ""

  if lastpage > 1 then

   pagination = pagination & "<div class=""pagination"""

   if margin <> "" OR padding <> "" then

    pagination = pagination & " style="""

    if margin <> "" then

     pagination = pagination & "margin: margin"

    end if

    if padding <> "" then

     pagination = pagination & "padding: padding"

    end if

    pagination = pagination & """"

   end if

   pagination = pagination & ">"

 

   'previous button

   if page > 1 then

    pagination = pagination & "<a href="""&targetpage&"&page="&prev&""">Prev</a>"

   else

    pagination = pagination & "<span class=""disabled"">Prev</span>" 

   end if

   'pages 

   if lastpage < 7 + (adjacents * 2) then 'not enough pages to bother breaking it up    for counter = 1 to lastpage

(编辑:银川站长网)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章