<%
'------------------------------------------------------------
'------------------------------------------------------------
CLASS pagination
Public PageSize ' How many records are displayed per page
Public AbsolutePage ' current page
Public BaseURL ' URL of the page to jump
Public basequerystring ' Page the original querystring
Public rst ' converted Recordset
Public Pagelistcount ' The number of pages listed below ...
Public Beginposition ' Where does the record start
Public Endposition '
Public Pagelistforreturn ' Add by Jeanun 2008.11.13
PRIVATE Sub Class_Initialize ' constructor.
PageSize =20
Absolutepage=request. QueryString ("page")
BaseURL =request. ServerVariables ("URL")
basequerystring = ""
Set Rst=server. CreateObject ("ADODB.") RecordSet ")
Pagelistcount =10
Dim o
For each o in Request.QueryString
If o<> "page" Then
basequerystring= basequerystring & O & "=" & Request.QueryString (O) & "&"
End If
Next
If not IsNumeric (AbsolutePage) Then
AbsolutePage = 1 ' can not be combined with the following conditions of judgment, otherwise, will be prompted to error, think Impassability!
End If
If trim (absolutepage) = "" or absolutepage<=0 Then
AbsolutePage = 1 ' note, not starting from 0. Don't believe you can try.
End If
Absolutepage=cint (AbsolutePage)
End Sub
Public SUB SetValue (PRST)
Set Rst=prst
Rst.pagesize =pagesize
If Cint (absolutepage) >rst.pagecount Then
Absolutepage=rst.pagecount
End If
If not rst.eof then
Rst.absolutepage=absolutepage
Beginposition =rst.absoluteposition
Else
Beginposition =0
End If
Endposition =beginposition+pagesize-1
If Endposition>rst.recordcount Then
Endposition=rst.recordcount
End If
End SUB
Public SUB PageList
If Rst.recordcount>0 Then
Dim startnum
Startnum=int ((absolutePage-1)/pagelistcount) *pagelistcount+1
' Formula: Int ((n-1)/col) *col+1 n given parameters col each row shows several numbers starting from 1, sequential rows
If Absolutepage<>1 Then
Response.Write ("<span class= ' inactivepage ' ><a href= '" &baseURL& "?page=1&" & basequerystring& "' title= ' first page ' >|<</a></span>")
End If
If Startnum-pagelistcount>0 Then
Response.Write ("<span class= ' inactivepage ' ><a href= '" &baseURL& "? page=" & ( Startnum-pagelistcount) & "&" &baseQueryString& "' title= ' pre" &pageListCount& "page ' >< <</a></span> ")
End If
For I=startnum to Startnum+pagelistcount-1
If I=absolutepage Then
Classname= "ActivePage"
Else
Classname= "Inactivepage"
End If
Response.Write ("<span class=" "&className&" ' ><a href= ' "&baseURL&"? page= "&i&" & "&baseQueryString&" ' > "&i&" </a></span> ")
If I>=rst.pagecount Then
Exit For
End If
Next
If Startnum+pagelistcount<=rst.pagecount Then
Response.Write ("<span class= ' inactivepage ' ><a href= '" &baseURL& "? page=" & startnum+ Pagelistcount) & "&" &baseQueryString& "' title= ' after" &pageListCount& "Page ' >>> </a></span> ")
End If
If Absolutepage<>rst.pagecount Then
Response.Write ("<span class= ' inactivepage ' ><a href= '" &baseURL& "? page=" &rst.pagecount& " & "&baseQueryString&" ' title= ' last page ' >>|</a></span> ')
End If
End IF
End Sub
Public Sub Pagelist4return
If Rst.recordcount>0 Then
Dim startnum
Startnum=int ((absolutePage-1)/pagelistcount) *pagelistcount+1
' Formula: Int ((n-1)/col) *col+1 n given parameters col each row shows several numbers starting from 1, sequential rows
If Absolutepage<>1 Then
Pagelistforreturn = "<span class= ' inactivepage ' ><a href= '" "&baseURL&"?page=1& "& basequerystring& "' title= ' first page ' >|<</a></span>"
End If
If Startnum-pagelistcount>0 Then
Pagelistforreturn = Pagelistforreturn & "<span class= ' inactivepage ' ><a href= '" &baseURL& "? page=" & (Startnum-pagelistcount) & "&" &baseQueryString& "' title= ' before" &pageListCount& "Page ' > <<</a></span> "
End If
For I=startnum to Startnum+pagelistcount-1
If I=absolutepage Then
Classname= "ActivePage"
Else
Classname= "Inactivepage"
End If
Pagelistforreturn = Pagelistforreturn & "<span class= '" &className& "' ><a href= '" &baseurl & "? page=" &i& "&" &baseQueryString& "' >" &i& "</a></span>"
If I>=rst.pagecount Then
Exit For
End If
Next
If Startnum+pagelistcount<=rst.pagecount Then
Pagelistforreturn = Pagelistforreturn & "<span class= ' inactivepage ' ><a href= '" &baseURL& "? page=" & (Startnum+pagelistcount) & "&" &baseQueryString& "' title= ' after" &pageListCount& "Page ' > >></a></span> "
End If
If Absolutepage<>rst.pagecount Then
Pagelistforreturn = Pagelistforreturn & "<span class= ' inactivepage ' ><a href= '" &baseURL& "? page=" &rst.pagecount& "&" &baseQueryString& "' title= ' last page ' >>|</a></span> '
End If
Pagelistforreturn = Pagelistforreturn & " <input type= ' text ' id= ' gotopagevaluebox ' style= '" " width:20px "" "Onpropertychange=" "document.getElementById (' Gotopagelink '). href= '" &baseURL& "page= ' + This.value+ ' & ' &baseQueryString& "'" "Onchange=" "document.getElementById (' Gotopagelink '). href= '" & baseurl& "? page= ' +this.value+ ' &" &baseQueryString& "" "/> <span class= ' activepage ' ><a ID = ' Gotopagelink ' href= ' # ' >Go!</a></span> '
End IF
End Sub
End CLASS
%>
How to call the above paging type
<table width= "100%" border= "0" cellspacing= "0" cellpadding= "5"
<tr>
<td align= "Center" > A total <%=mypagination.rst.recordcount%> bar record current <%=mypagination.absolutepage%>/<%= Mypagination.rst.pagecount%> page
<% mypagination.pagelist%></td>
< /tr>
</table>