<%
'===================================================================
'XDOWNPAGE ASP version
'version 1.00
'Code by zykj2000
'Email: zykj_2000@
'BBS: http://bbs.
'This program can be used and modified for free. I hope my program can bring convenience to your work
'But please keep the above please refusal
'
'Program Features
'This program mainly encapsulates the data paging part, and the data display part is completely customized by the user.
'Support multiple URL parameters
'
'Instructions for use
'Program Parameter Description
'PapgeSize Define the number of records for each page of the paging page
'GetRS Returns the paged Recordset This property is read only
'GetConn GetConn GetConn
'GetSQL Get the query statement
'Program method description
'ShowPage ShowPage ShowPagination Navigation Bar, the only public method
'
'===================================================================
Const Btn_First="<font face=""webdings"">9</font>" 'Define the display style of the button on the first page
Const Btn_Prev="<font face=""webdings"">3</font>" 'Define the button display style on the previous page
Const Btn_Next="<font face=""webdings"">4</font>" 'Define the next page button display style
Const Btn_Last="<font face=""webdings"">:</font>" 'Define the last page button display style
Const XD_Align="Center" 'Define the alignment of paging information
Const XD_Width="100%" 'Define the size of the paging information box
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
'Set the page 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 parameter is 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 attribute
'Return to the paged recordset
'=================================================================
Public Property Get GetRs()
Set XD_Rs=("")
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 GetConn Get the database connection
'
'================================================================
Public Property Let GetConn(obj_Conn)
Set XD_Conn=obj_Conn
End Property
'================================================================
'GetSQL GetQuery
'
'================================================================
Public Property Let GetSQL(str_sql)
XD_SQL=str_sql
End Property
'==================================================================
'Class_Initialize class initialization
'Initialize the value of the current page
'
'==================================================================
Private Sub Class_Initialize
'========================
'Set the recognition value of some parameters
'========================
XD_PageSize=10 'Set the default value of paging is 10
'========================
'Get the current value
'========================
If request("page")="" Then
int_curpage=1
ElseIf not(IsNumeric(request("page"))) Then
int_curpage=1
ElseIf CInt(Trim(request("page")))<1 Then
int_curpage=1
Else
Int_curpage=CInt(Trim(request("page")))
End If
End Sub
'====================================================================
'ShowPage Create a paging navigation bar
'There are home page, previous page, next page, last page, and 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 & "The total number of records 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=int_TotalPage
End If
'==================================================================
'Display paging information, and each module changes the display position according to its own requirements
'==================================================================
""
str_tmp=ShowFirstPrv
str_tmp
str_tmp=showNumBtn
str_tmp
str_tmp=ShowNextLast
str_tmp
str_tmp=ShowPageInfo
str_tmp
""
End Sub
'====================================================================
'ShowFirstPrv Show the home page, the previous page
'
'
'====================================================================
Private Function ShowFirstPrv()
Dim Str_tmp,int_prvpage
If int_curpage=1 Then
str_tmp=Btn_First&" "&Btn_Prev
Else
int_prvpage=int_curpage-1
str_tmp="<a href="""&XD_sURL & "1" & """>" & Btn_First&"</a> <a href=""" & XD_sURL & CStr(int_prvpage) & """>" & Btn_Prev&"</a>"
End If
ShowFirstPrv=str_tmp
End Function
'====================================================================
'ShowNextLast Next, Last Page
'
'
'====================================================================
Private Function ShowNextLast()
Dim str_tmp,int_Nextpage
If Int_curpage>=int_totalpage Then
str_tmp=Btn_Next & " " & Btn_Last
Else
Int_NextPage=int_curpage+1
str_tmp="<a href=""" & XD_sURL & CStr(int_nextpage) & """>" & Btn_Next&"</a> <a href="""& XD_sURL & CStr(int_totalpage) & """>" & Btn_Last&"</a>"
End If
ShowNextLast=str_tmp
End Function
'====================================================================
'ShowNumBtn Digital Navigation
'
'
'====================================================================
Private Function showNumBtn()
Dim i,str_tmp
For i=1 to int_totalpage
str_tmp=str_tmp & "[<a href=""" & XD_sURL & CStr(i) & """>"&i&"</a>] "
Next
showNumBtn=str_tmp
End Function
'====================================================================
'ShowPageInfo Pagination Information
'Modify it yourself as required
'
'====================================================================
Private Function ShowPageInfo()
Dim str_tmp
str_tmp="page:"&int_curpage&"/"&int_totalpage&"pages Total"&int_totalrecord&" records "&XD_PageSize&"bar/per page"
ShowPageInfo=str_tmp
End Function
'==================================================================
'GetURL Get the current URL
'More, different results are obtained according to different URL parameters
'
'==================================================================
Private Function GetURL()
Dim strurl,str_url,i,j,search_str,result_url
search_str="page="
strurl=("URL")
Strurl=split(strurl,"/")
i=UBound(strurl,1)
str_url=strurl(i)'get the file name of the current page
str_params=Trim(("QUERY_STRING"))
If str_params="" Then
result_url=str_url & "?page="
Else
If InstrRev(str_params,search_str)=0 Then
result_url=str_url & "?" & str_params &"&page="
Else
j=InstrRev(str_params,search_str)-2
If j=-1 Then
result_url=str_url & "?page="
Else
str_params=Left(str_params,j)
result_url=str_url & "?" & str_params &"&page="
End If
End If
End If
GetURL=result_url
End Function
'====================================================================
' Set the Terminate event.
'
'====================================================================
Private Sub Class_Terminate
XD_RS.close
Set XD_RS=nothing
End Sub
'====================================================================
'ShowError Error prompt
'
'
'====================================================================
Private Sub ShowError()
If str_Error <> "" Then
("" & str_Error & "")
End If
End Sub
End class
'set conn = ("")
' "driver={microsoft access driver (*.mdb)};dbq=" & ("/data/")
'
''############################################
''Create an object
'Set mypage=new xdownpage
''Get the database connection
'=conn
''sql statement
'="select * from [DH_Company] order by id asc"
''Set the record data on each page to 5
'=5
''Return to Recordset
'set rs=()
'Show paging information, this method can be called at any location after set rs=(), and can be called multiple times
'
''Show data
'("<br/>")
'for i=1 to
''You can customize the display method here
' if not then
' rs(0) & "<br/>"
'
' else
' exit for
' end if
'next
'()
%>
'===================================================================
'XDOWNPAGE ASP version
'version 1.00
'Code by zykj2000
'Email: zykj_2000@
'BBS: http://bbs.
'This program can be used and modified for free. I hope my program can bring convenience to your work
'But please keep the above please refusal
'
'Program Features
'This program mainly encapsulates the data paging part, and the data display part is completely customized by the user.
'Support multiple URL parameters
'
'Instructions for use
'Program Parameter Description
'PapgeSize Define the number of records for each page of the paging page
'GetRS Returns the paged Recordset This property is read only
'GetConn GetConn GetConn
'GetSQL Get the query statement
'Program method description
'ShowPage ShowPage ShowPagination Navigation Bar, the only public method
'
'===================================================================
Const Btn_First="<font face=""webdings"">9</font>" 'Define the display style of the button on the first page
Const Btn_Prev="<font face=""webdings"">3</font>" 'Define the button display style on the previous page
Const Btn_Next="<font face=""webdings"">4</font>" 'Define the next page button display style
Const Btn_Last="<font face=""webdings"">:</font>" 'Define the last page button display style
Const XD_Align="Center" 'Define the alignment of paging information
Const XD_Width="100%" 'Define the size of the paging information box
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
'Set the page 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 parameter is 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 attribute
'Return to the paged recordset
'=================================================================
Public Property Get GetRs()
Set XD_Rs=("")
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 GetConn Get the database connection
'
'================================================================
Public Property Let GetConn(obj_Conn)
Set XD_Conn=obj_Conn
End Property
'================================================================
'GetSQL GetQuery
'
'================================================================
Public Property Let GetSQL(str_sql)
XD_SQL=str_sql
End Property
'==================================================================
'Class_Initialize class initialization
'Initialize the value of the current page
'
'==================================================================
Private Sub Class_Initialize
'========================
'Set the recognition value of some parameters
'========================
XD_PageSize=10 'Set the default value of paging is 10
'========================
'Get the current value
'========================
If request("page")="" Then
int_curpage=1
ElseIf not(IsNumeric(request("page"))) Then
int_curpage=1
ElseIf CInt(Trim(request("page")))<1 Then
int_curpage=1
Else
Int_curpage=CInt(Trim(request("page")))
End If
End Sub
'====================================================================
'ShowPage Create a paging navigation bar
'There are home page, previous page, next page, last page, and 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 & "The total number of records 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=int_TotalPage
End If
'==================================================================
'Display paging information, and each module changes the display position according to its own requirements
'==================================================================
""
str_tmp=ShowFirstPrv
str_tmp
str_tmp=showNumBtn
str_tmp
str_tmp=ShowNextLast
str_tmp
str_tmp=ShowPageInfo
str_tmp
""
End Sub
'====================================================================
'ShowFirstPrv Show the home page, the previous page
'
'
'====================================================================
Private Function ShowFirstPrv()
Dim Str_tmp,int_prvpage
If int_curpage=1 Then
str_tmp=Btn_First&" "&Btn_Prev
Else
int_prvpage=int_curpage-1
str_tmp="<a href="""&XD_sURL & "1" & """>" & Btn_First&"</a> <a href=""" & XD_sURL & CStr(int_prvpage) & """>" & Btn_Prev&"</a>"
End If
ShowFirstPrv=str_tmp
End Function
'====================================================================
'ShowNextLast Next, Last Page
'
'
'====================================================================
Private Function ShowNextLast()
Dim str_tmp,int_Nextpage
If Int_curpage>=int_totalpage Then
str_tmp=Btn_Next & " " & Btn_Last
Else
Int_NextPage=int_curpage+1
str_tmp="<a href=""" & XD_sURL & CStr(int_nextpage) & """>" & Btn_Next&"</a> <a href="""& XD_sURL & CStr(int_totalpage) & """>" & Btn_Last&"</a>"
End If
ShowNextLast=str_tmp
End Function
'====================================================================
'ShowNumBtn Digital Navigation
'
'
'====================================================================
Private Function showNumBtn()
Dim i,str_tmp
For i=1 to int_totalpage
str_tmp=str_tmp & "[<a href=""" & XD_sURL & CStr(i) & """>"&i&"</a>] "
Next
showNumBtn=str_tmp
End Function
'====================================================================
'ShowPageInfo Pagination Information
'Modify it yourself as required
'
'====================================================================
Private Function ShowPageInfo()
Dim str_tmp
str_tmp="page:"&int_curpage&"/"&int_totalpage&"pages Total"&int_totalrecord&" records "&XD_PageSize&"bar/per page"
ShowPageInfo=str_tmp
End Function
'==================================================================
'GetURL Get the current URL
'More, different results are obtained according to different URL parameters
'
'==================================================================
Private Function GetURL()
Dim strurl,str_url,i,j,search_str,result_url
search_str="page="
strurl=("URL")
Strurl=split(strurl,"/")
i=UBound(strurl,1)
str_url=strurl(i)'get the file name of the current page
str_params=Trim(("QUERY_STRING"))
If str_params="" Then
result_url=str_url & "?page="
Else
If InstrRev(str_params,search_str)=0 Then
result_url=str_url & "?" & str_params &"&page="
Else
j=InstrRev(str_params,search_str)-2
If j=-1 Then
result_url=str_url & "?page="
Else
str_params=Left(str_params,j)
result_url=str_url & "?" & str_params &"&page="
End If
End If
End If
GetURL=result_url
End Function
'====================================================================
' Set the Terminate event.
'
'====================================================================
Private Sub Class_Terminate
XD_RS.close
Set XD_RS=nothing
End Sub
'====================================================================
'ShowError Error prompt
'
'
'====================================================================
Private Sub ShowError()
If str_Error <> "" Then
("" & str_Error & "")
End If
End Sub
End class
'set conn = ("")
' "driver={microsoft access driver (*.mdb)};dbq=" & ("/data/")
'
''############################################
''Create an object
'Set mypage=new xdownpage
''Get the database connection
'=conn
''sql statement
'="select * from [DH_Company] order by id asc"
''Set the record data on each page to 5
'=5
''Return to Recordset
'set rs=()
'Show paging information, this method can be called at any location after set rs=(), and can be called multiple times
'
''Show data
'("<br/>")
'for i=1 to
''You can customize the display method here
' if not then
' rs(0) & "<br/>"
'
' else
' exit for
' end if
'next
'()
%>