ASP Paging Code

Source: Internet
Author: User
Paging

Using ASP to do things already more, but has not paid attention to this thing, today spent a little time to write some, easy to use later.

<%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 (objRS.EOF and objRS. BOF)) Then
Rstotal=0
Do as 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> </td>
<td> </td>
</tr>
</table>
<%end sub%>



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.