ASP Classic Page-type

Source: Internet
Author: User
Pagination ' =====================================================================
' 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 interest
'
' Program features
' This program is mainly to the data pagination part of the encapsulation, and the data display part completely by the user customization,
' Support URL multiple parameters
'
' Use instructions
' Program parameter description
' Papgesize defines the number of records per page of pagination
' Getrs Returns a paging recordset this property is read-only
' Getconn get a database connection
' GetSQL get the query statement
' Procedure Method description
' ShowPage display the pager bar, the only common method
'
Cases
'
' Include file
'
' Set mypage=new xdownpage ' Create object
' Mypage.getconn=conn ' Get database connection
' mypage.getsql= ' select * from ProductInfo ORDER by ID ASC
' Mypage.pagesize=5 ' Sets the record bar data for each page to 5
' Set Rs=mypage.getrs () ' returns to the recordset
' Mypage.showpage () ' Displays paging information, which can be used after set Rs=mypage.getrs ()
' Call anywhere, you can call multiple times
' For I=1 to Mypage.pagesize ' The next action is the same as manipulating a normal Recordset object
' If not rs.eof then ' this tag is to prevent last page overflow
' Response.Write Rs (0) & "
"' Here's the way to customize the display.
' Rs.movenext
' Else
' Exit for
' End If
' Next
'
'=====================================================================

Const btn_first= "9" Defines the first page button display style
Const btn_prev= "3" defines the previous-page button display style
Const btn_next= "4" defines the next-page button display style
Const btn_last= ":" Defines the last-page button display style
Const xd_align= "Center" defines the alignment of pagination information
Const xd_width= "100%" Defines the paging information box size
Const xd_height= "20"
Class Xdownpage
Private Xd_pagecount,xd_conn,xd_rs,xd_sql,xd_pagesize,str_errors,int_curpage,str_url,int_totalpage,int_ Totalrecord


'=================================================================
' PageSize Property
' Set the paging size of 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 the query statement
'
'================================================================
Public Property Let GetSQL (Str_sql)
Xd_sql=str_sql
End Property



'==================================================================
' Initialization of the Class_Initialize class
' Initialize the value of the current page
'
'==================================================================
Private Sub Class_Initialize
'========================
' Set some parameters of the Summerside recognition value
'========================
xd_pagesize=10 ' Sets the default value of paging to 10
'========================
' Get when the previous value
'========================
If Request ("page") = "" Then
Int_curpage=1
ElseIf Not (IsNumeric (Request ("page")) Then
Int_curpage=1
ElseIf CInt ("page") <1 Then
Int_curpage=1
Else
Int_curpage=cint Trim (Request ("page"))
End If

End Sub

'====================================================================
' ShowPage Create a pager bar
' There's a homepage, a previous page, the next page, the last, and the digital navigation
'
'====================================================================
Public Sub ShowPage ()
Dim str_tmp

Int_totalrecord=xd_rs. RecordCount
If int_totalrecord<=0 Then
Str_error=str_error & "Total record number is zero, please enter data"



Related Article

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.