程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
 程式師世界 >> 編程語言 >> 網頁編程 >> ASP編程 >> 關於ASP編程 >> 一個實用asp分頁函數

一個實用asp分頁函數

編輯:關於ASP編程

    分享一個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
    %>

    1. 上一頁:
    2. 下一頁:
    Copyright © 程式師世界 All Rights Reserved