Paging <%
'===================================================================
' xdownpage ASP version
' version 1.00
' Code by zykj2000
' Email:zykj_2000@163.net
' Bbs:http://bbs.513soft.net
' This program can be free to use, modify, I hope my program can bring convenience to your work
' But please keep the above please
'
' program features
' This program is mainly to the data pagination part of the encapsulation, and the data display part is completely user-defined,
' supports multiple parameters for URLs
'
' Use instructions
' program parameter description
' papgesize defines the number of records per page of paging
' Getrs Returns a paging recordset this property is read-only
' Getconn get a database connection
' getsql get query statement
' Procedure method description
' showpage Displays the pager bar, the only common method
'
'===================================================================
Const btn_first= "<font face=" "Webdings" ">9</font>" defines the first-page button display style
Const btn_prev= "<font face=" "Webdings" ">3</font>" defines the previous-page button display style
Const btn_next= "<font face=" "Webdings" ">4</font>" defines the next-page button display style
Const btn_last= "<font face=" "Webdings" ">:</font>" defines the last-page button display style
Const xd_align= "Center" defines the paging information alignment
Const xd_width= "100%" Defines the paging information box size
Class xdownpage
Private Xd_pagecount,xd_conn,xd_rs,xd_sql,xd_pagesize,str_errors,int_curpage,str_url,int_totalpage,int_ Totalrecord,xd_surl
'=================================================================
' PageSize Property
' Sets the paging size for each page
'=================================================================
Public Property Let PageSize (Int_pagesize)
If isnumeric (int_pagesize) Then
xd_pagesize=clng (int_pagesize)
Else
Str_error=str_error & "pagesize parameters are incorrect"
ShowError ()
End If
End Property
Public Property Get PageSize
If xd_pagesize= "" or (Not (IsNumeric (xd_pagesize)) Then
pagesize=10
Else
pagesize=xd_pagesize
End If
End Property
'=================================================================
' Getrs Property
' Returns a paginated recordset
'=================================================================
Public Property Get Getrs ()
Set xd_rs=server.createobject ("Adodb.recordset")
xd_rs.pagesize=pagesize
Xd_rs.open xd_sql,xd_conn,1,1
If not (xd_rs.eof and xd_rs. BOF) Then
If int_curpage>xd_rs. PageCount Then
int_curpage=xd_rs. PageCount
End If
Xd_rs.absolutepage=int_curpage
End If
Set getrs=xd_rs
End Property
'================================================================
' Getconn get a database connection
'
'================================================================
Public Property Let Getconn (Obj_conn)
Set Xd_conn=obj_conn
End Property
'================================================================
' getsql get query statement
'
'================================================================
Public Property Let GetSQL (Str_sql)
Xd_sql=str_sql
End Property
'==================================================================
Initialization of the
' Class_Initialize class
' Initializes the value of the current page
'
'==================================================================
Private Sub Class_Initialize
'========================
' Sets the Summerside recognition value of some parameters
'========================
The default value for
xd_pagesize=10 ' set paging is 10
'========================
' gets when the previous value
'========================
If Request ("page") = "" Then
int_curpage=1
ElseIf Not (IsNumeric (Request ("page")) Then
int_curpage=1
ElseIf CInt ("Request (" page)) <1 Then
int_curpage=1
Else
Int_curpage=cint ("Request (" page))
End If
End Sub
'====================================================================
' showpage Create a pager bar
' has the homepage, the previous page, the next page, the last, and the digital navigation
'
'====================================================================
public Sub showpage ()
Dim str_tmp
Xd_surl = GETURL ()
int_totalrecord=xd_rs. RecordCount
If int_totalrecord<=0 Then
Str_error=str_error & "Total record number is zero, please enter data"
call ShowError ()
End If
If int_totalrecord= "" Then
int_totalpage=1
Else
If int_totalrecord mod PageSize =0 Then
int_totalpage = CLng (int_totalrecord/xd_pagesize *-1) *-1
Else
int_totalpage = CLng (int_totalrecord/xd_pagesize *-1) *-1+1
End If
End If
If int_curpage>int_totalpage Then
Int_curpage