一个实用asp分页函数

2015-08-12 16:02:23来源:作者:人点击

分享一个asp分页函数,感觉挺好看的。视图如图:
 

一个实用asp分页函数 第七城市
 

可以根据自己的情况修改,代码:

<%
'谢亮修分页程序
'call pagecontrol(记录总数,页码总数,当前页)
Sub PageControl(iCount,pagecount,page)
 response.Write("<style type=""text/css"">/*谢亮分页CSS*/div.pager{padding:10px;}div.pager a,div.pager span{padding:2px 5px;margin:2px;font-family:""宋体"";border:1px #363 solid;}div.pager a {text-decoration:none}div.pager a:hover {color:#000;background-color:#363}div.pager span.current {font-weight:bold;color:#fff;background-color:#363}div.pager span.disabled {border:1px #ccc solid;}</style>") &chr(13)
    Dim query, a, x, temp
    action = "http://" & Request.ServerVariables("HTTP_HOST") & Request.ServerVariables("SCRIPT_NAME")
    query = Split(Request.ServerVariables("QUERY_STRING"), "&")
    For Each x In query
        a = Split(x, "=")
        If StrComp(a(0), "page", vbTextCompare) <> 0 Then
            temp = temp & a(0) & "=" & a(1) & "&"
        End If
    Next
 response.Write("<div class=""pager"">")&chr(13)
 Response.Write("<span class=""disabled"">" & page & "/" & pageCount & "页</span>")&chr(13)
    Response.Write("<span class=""disabled"">共" & iCount & "条记录</span>")&chr(13)
    if pagecount<=6 then
  for xl=1 to pagecount
   if page=xl then
    response.Write("<span class='current'>"&xl&"</span>")&chr(13)
   else
    Response.Write("<a href='" & action & "?" & temp & "Page="&xl&"'>"&xl&"</a> ")&chr(13)
   end if
  next
 else
  if page=1 then
   response.Write("<span class='current'>1</span>")&chr(13)
  else
   Response.Write("<a href='" & action & "?" & temp & "Page=1'>1</a> ")&chr(13)
  end if
  if page>4 then Response.Write("<span class=""disabled"">...</span>")&chr(13)
  if page<5 then i1=1 else i1=page-2
  if page > (pagecount-4) then i2=pagecount else i2=page+3
  for xll=i1 to i2
   
   if xll<>1 and xll <> pagecount then
    if xll=page then
     response.Write("<span class='current'>"&xll&"</span>")&chr(13)
    else
     Response.Write("<a href=""" & action & "?" & temp & "Page="&xll&""">"&xll&"</a>")&chr(13)
    end if
   end if
  
  next
  if page< (pagecount-4) then Response.Write("<span class=""disabled"">...</span>") &chr(13)
  if page=pagecount then response.Write("<span class='current'>"&pagecount&"</span>")&chr(13) else Response.Write("<a href='" & action & "?" & temp & "Page="&pagecount&"'>"&pagecount&"</a> ") &chr(13)
 end if
 response.Write("</div>")&chr(13)
End Sub
%>

最新文章

123

最新摄影

微信扫一扫

第七城市微信公众平台