Paging <%
'-------------------------------------------
Interface
Property
' A, Tip: project hints (e.g., "article");
' B, tablewidth: jump page navigation width
Method
' A, Setrsobj () method: Set the Adodb.recordset object;
' B, Controlpages () Method: Show jump page navigation (previous page, next page ...) )
' C, SetParams () method: Set parameter array
Example
' Dim params (1,1)
' params (0,0) = "Query": params (0,1) = Request ("Query")
' params (1,0) = "keyword": params (1,1) = Request ("keyword")
' The array mainly passes query keywords (such as field keywords, time, etc.), the first dimension is the parameter name, and the second dimension is the parameter value: the following http://.......asp?topage=2&query=yes&keyword=a
'
' Set PageCtrl = new Cpagectrl
' Pagectrl.setrsobj (RS) ' Sets the Adodb.recordset object, where RS is the established Adodb.recordset, which is the recordset to control
' Pagectrl.tip = ' article '
' Pagectrl.tablewidth = ' 100% '
' Pagectrl.setparams params
' Pagectrl.dimpage (15) ' Paging definition, 15 records per page
' Pagectrl.controlpages () ' Show jump page navigation
'-------------------------------------------
Class Cpagectrl
Public Tip, Tablewidth
Private Setobjflag, rsobj, pages, record, Setparamsflag, current, topage
Dim params ()
'----------------------------------
Private Sub Class_Initialize ()
Tablewidth = "100%"
End Sub
'---------------------------------
Public function setrsobj (obj)
Set rsobj = obj
Setobjflage = True
End Function
'----------------------------------
Private Function Chksetobj ()
If Setobjflage <> true Then response. End ()
End Function
'----------------------------------
Public Function Dimpage (psize) ' Paging definition
Dim topages
ToPage = Request ("ToPage")
If not rsobj.eof then
If not IsEmpty (psize) Then
Rsobj.pagesize = CInt (psize) ' defines the number of display per page
Else
Rsobj.pagesize = Rsobj.recordcount
End If
Pages = Rsobj.pagecount
Record = Rsobj.recordcount
If ToPage <> empty Then
Topages = CInt (topage)
If ToPage <= 1 Then
Rsobj.absolutepage = 1
ElseIf topages >= pages Then
Rsobj.absolutepage = pages
Else
Rsobj.absolutepage = Topages
End If
End If
Current = Rsobj.absolutepage
End If
End Function
'----------------------------------
Public Function SetParams (Arrparams ())
params = Arrparams
Setparamsflag = True
End Function
'----------------------------------
Public Function Controlpages ()
Dim url
url = "http://" & request. ServerVariables ("Http_host") & request. ServerVariables ("URL")
If Setparamsflag = True Then
row = UBound (params,1)
Col = UBound (params,2)
If Col <> 1 Then
Exit function
End If
For i = 0 to row
If params (i,0) <> empty Then
Condition = condition & "&" & Params (i,0) & "=" & Params (i,1)
' Generate parameters
End If
Next
End If
Response.Write "<table width=" "& Tablewidth &" ' border= ' 0 ' cellspacing= ' 0 ' cellpadding= ' 0 ' > '
Response.Write "<form action= '" & URL & "' method= ' post ' > '
Response.Write "<tr>"
Response.Write "<td height=" > currently has a total of <font color= ' red ' ><b> ' & Record & ' </b></font& Gt & Tip & Current paging status <font color= ' red ' ><b> ' & Current & '/' & pages & ' </b></fon T></td> "
If current <> 1 Then
Response.Write "<td width= ' align= ' center ' height= ' >"
Response.Write "<a href= '" & URL & "? topage=1" & Condition & "' > Home </a> '
Response.Write "</td>"
Response.Write "<td width= ' align= ' center ' height= ' >"
Response.Write "<a href= '" & URL & "? topage=" & Current-1 & Condition & "' > previous page </a> '
Response.Write "</td>"
Else
Response.Write "<td width= ' align= ' center ' height= ' >"
Response.Write "<font color= ' #999999 ' > Home </font>"
Response.Write "</td>"
Response.Write "<td width= ' align= ' center ' height= ' >"
Response.Write "<font color= ' #999999 ' > Prev </font>"
Response.Write "</td>"
End If
If current <> pages then
Response.Write