• 欢迎访问搞代码网站,推荐使用最新版火狐浏览器和Chrome浏览器访问本网站!
  • 如果您觉得本站非常有看点,那么赶紧使用Ctrl+D 收藏搞代码吧

ASP 数字分页效果代码

asp 搞代码 4年前 (2022-01-03) 30次浏览 已收录 0个评论

最近网站改版正好发现原来的分页不带数字的,只有首页 上页 下页 末页 然后是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
     pagin来源gaodai$ma#com搞$代*码网ation = 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 &  “Prev”
   else
    pagination = pagination &  “Prev” 
   end if
   ‘pages 
   if lastpage <7 + (adjacents * 2) then 'not enough pages to bother breaking it up

    for counter = 1 to lastpage

     if counter = page then
      pagination = pagination &  ““&counter&”
     else
      pagination = pagination &  “”&counter&””
     end if
    next 
   elseif lastpage >= 7 + (adjacents * 2) then ‘enough pages to hide some
    ‘close to beginning only hide later pages
    if page <1 + (adjacents * 3) then 
     for counter = 1 to (4 + (adjacents * 2))-1
      if counter = page then
       pagination = pagination &  ““&counter&”
      else
       pagination = pagination &  “”&counter&””
      end if   
     next
     pagination = pagination &  “…”
     pagination = pagination &  “”&lpm1&””
     pagination = pagination &  “”&lastpage&””  
    ‘in middle hide some front and some back
    elseif lastpage – (adjacents * 2) > page AND page > (adjacents * 2) then
     pagination = pagination &  “1”
     pagination = pagination &  “2”
     pagination = pagination &  “…”
     for counter = (page – adjacents) to (page + adjacents)
      if counter = page then
       pagination = pagination &  ““&counter&”
      else
       pagination = pagination &  “”&counter&””
      end if
     next
     pagination = pagination &  “…”
     pagination = pagination &  “”&lpm1&””
     pagination = pagination &  “”&lastpage&””  
    ‘close to end only hide early pages
    else
     pagination = pagination &  “1”
     pagination = pagination &  “2”
     pagination = pagination &  “…”
     for counter = (lastpage – (1 + (adjacents * 3))) To lastpage
      if counter = page then
       pagination = pagination &  ““&counter&”
      else
       pagination = pagination &  “”&counter&””
      end if
     next
    end if
   end if
   ‘nextPage button
   if page <counter – 1 then
    pagination = pagination &  “Next”
   else
    pagination = pagination &  “Next
   end if
   pagination = pagination &  “

” & vbnewline
  end if
  getPaginationString = pagination
 end function
 function Ceil( dividend, divider)
  if (dividend mod divider) = 0 Then
   Ceil = dividend / divider
  ELSE
   Ceil = Int(dividend / divider) + 1
  End if
    End function
 ‘test script code
 page = 1
 if request(“page”) “” then
  page=cint(request(“page”))
 end if
 ps = getPaginationString(page, 1500, 15, 2, “pagination.asp?foo=bar”)
 Response.Write(“

“&ps)
%>

以上就是ASP 数字分页效果代码的详细内容,更多请关注gaodaima搞代码网其它相关文章!


搞代码网(gaodaima.com)提供的所有资源部分来自互联网,如果有侵犯您的版权或其他权益,请说明详细缘由并提供版权或权益证明然后发送到邮箱[email protected],我们会在看到邮件的第一时间内为您处理,或直接联系QQ:872152909。本网站采用BY-NC-SA协议进行授权
转载请注明原文链接:ASP 数字分页效果代码

喜欢 (0)
[搞代码]
分享 (0)
发表我的评论
取消评论

表情 贴图 加粗 删除线 居中 斜体 签到

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址