asp 分頁代碼

來源:互聯網
上載者:User

使用asp作東西已經比較多了,但是一直沒有注意這個東西,今天就花了一點時間寫了一些,方便以後使用。

<%SUB ListPageMenu(objRs,intrsPageSize)
 Dim rsTotal,rsPageSize,rsPageCount
 If NOT ISObject(objRs) Then Exit Sub:End If
 If NOT IsNumeric(rsPageSize) Then Exit Sub:End IF
 If objRs.Eof And objRs.Bof Then EXIT SUB:END IF
 
 objRs.PageSize=intrsPageSize
 rsTotal=objRs.RecordCount
 rsPageCount=rs.PageCount
 
 If rsTotal<0 AND (NOT (objRs.eof AND objrs.Bof))Then
  rsTotal=0
  DO WHILE NOT objRs.Eof
   rsTotal=rsTotal+1
   objRs.MoveNext
  LOOP
 End If
 
 intCurrentPage=Trim(Request.QueryString("page")) 'Get the value of intCurrentPage
 If intCurrentPage="" OR (NOT IsNumeric(intCurrentPage)) Then
  intCurrentPage=1
 End if
 
 Dim iStart,iStop
 iStart=1:iStop=1
 If Cint(intCurrentPage-3)>0 Then
  iStart=intCurrentPage-3
 Else
  iStart=1  
 End if
 iStop=iStart+7
 If iStop>rsPageCount Then
  iStop=rsPageCount
 End If
 If iStop-7<iStart AND iStart>0 Then
  iStart=iStop-7
 End If
 
 Dim strURL
 strURL=Request.ServerVariables("script_name")
 If Instr(strURL,"?")>0 Then
  strURL=strURL & "&page="
 Else
  strURL=strURL & "?page="
 End If
 
 Dim PreviousPage,NextPage
 If intCurrentPage-1>0 then
  PreviousPage=intCurrentPage-1
 Else
  PreviousPage=1
 End If
 If intCurrentPage+1<rsPageCount Then
  NextPage=intCurrentPage+1
 Else
  NextPage=rsPageCount
 End If%>
 <table width="98%" border="0" cellspacing="0" cellpadding="0">
   <tr>
  <td><a href="<%=strURL%>1" style="text-decoration:none"><font face="Webdings">9</font></a></td>
  <td><a href="<%=strURL & PreviousPage%>" style="text-decoration:none"><font face="Webdings">7</font></a></td>
  <td>
  <%Dim i
  For i=iStart to iStop Step 1%>
  <td><%response.write("<a href='" & strURL & i & "' style='text-decoration:none'>"& i &"</a>")%></td>
  <%Next%>
  </td>
  <td><a href="<%=strURL & NextPage %>" style="text-decoration:none"><font face="Webdings">8</font></a></td>
  <td><a href="<%=strURL & rsPageCount%>" style="text-decoration:none"><font face="Webdings">:</font></a></td>
  <td>&nbsp;</td>
  <td>&nbsp;</td>
   </tr>
 </table>
<%END SUB%>

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.