ASP paging code

Source: Internet
Author: User

ASP has been used for many tasks, but I have never paid attention to it. Today I have spent some time writing this item for future use.

<% 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
Pre viouspage = 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 %>

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

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.