A ASP paging class

xiaoxiao2021-03-05  27

<% '================================================ =====================rogous program characteristics 'This program is mainly packaged in the part of the data paging, and the data display is completely customized by the user,' support URL Multiple Parameters 'Use Descriptions' Program Parameter Description 'PapGesize Definition Points Each page records' getrs Return Extrap Pipeted RecordSet This property is read-only 'getConn gets the database connection' getSql get query statement 'program method Description' showpage display Sub-page navigation bar, unique common method '' example: 'set mypage = new DOWNPAGE' Create an object 'mypage.getconn = conn' Get database connection 'mypage.getsql = "select * from productinfo Order BY ID ASC"' mypage.pagesize = 5 'Sets the record strip data for each page to 5' set = mypage.getrs () 'Return RecordSet' mypage.showpage () 'Shows Pedimentation Information, this method can, in SET RS = mypage.getrs () In the future, 'any location call, you can call multiple' for i = 1 to mypage.pageSize 'Next operation, the next operation is to operate with a normal RecordSet object' if not xi ee 'this tag is to prevent the last page. Spilling 'response.write RS (0) & "'" here You can customize the display mode 'rs.movenext' else 'exit for' end if 'next' ============ ============================================================================================================================================================================================================= =====

Const btn_first = " 9 " Defines the first page button Display style const btn_prev = " 3 " Definition Previous Page button Display style const btn_next = " 4 " Definition Next button display style const btn_last = ": " Defined the last one page button display style Const XD_Align = "Center" 'custom paging information alignment Const XD_Width = "100%"' custom paging information block size Class downpagePrivate XD_PageCount, XD_Conn, XD_Rs, XD_SQL, XD_PageSize, Str_errors, int_curpage, str_URL, int_totalPage, int_totalRecord , LG, X_SHOWTYPE '=============================================== ==================== 'The initialization' initialization of the current page '================== ========================================================== pVate SUB class_initialize '========================' Sets some parameters 黙 recognition '============================================================================================================================================================================== =========== xd_pagesize = 20 'Set the default value of the paging is 20 x_showType = 1' ====

==================== 'Get the previous value' ======================== = If Request ("page") = "" "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 ("page"))) End if str_URL = getURL () end sub '======================== ======================================================================================================= To pull, 2 is the digital navigation bar '======================================= ========================= Public Property Let ShowType (show_type) x_showType = show_typend propertypublic property get showType ShowTyPE = x_showTypeEnd property '====== ============================================================================================================================================================================================================= ========= '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 parameter is incorrect "ShowError () End IfEnd PropertyPublic Property Get PageSize If XD_PageSize =" "or (not (IsNumeric (XD_PageSize))) Then PageSize = 20 Else PageSize = XD_PageSize End IfEnd Property '========== ============================================================================================================================================================================================================= ===== 'getrs attribute' After returning the recording set '================================= =============================== 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 int_TotalPage =

XD_rs.pagecount end if set getrs = xd_rsend print ======================================== ========================= 'getConn gets the database connection' ==================================================================================================================================== ===================================================== Public Property Let getConn Obj_conn) SET XD_CONN = Obj_Connend Property

'==================================================== =============== 'getSQL get query statement' ============================= ============================================ Public property let getsql (str_sql) xd_sql = str_sqlendprty '=== ============================================================================================================================================================================================================= =============== 'showpage created a paging navigation bar' has a home page, the previous page, the next page, the last page, there is a digital navigation, drop-down menu guide '=== ============================================================================================================================================================================================================= =============== Public SHOWPAGE () DIM STR_TMP INT_TOTALRECORD = XD_RS.RecordCount if int_totalRecord <= 0 THEN STR_ERROR = STR_ERROR & "The total record number is zero, please enter the data" Call showerror () End if if INT_CURPAGE> INT_TOTALPAGE THEN INT_CURPAGE =

INT_TOTALPAGE END IF '============================================== ===================== Show paging information, each module changes the location of the expansion "========================================================================================================================================================================== ============================================================================================================================================================================================================= = response.write "" response.write ShowFirstPrv 'show home page, previous page response.write showNumBtn' digital navigation response.write ShowNextLast 'next page, last page response.write ShowPageInfo' pagination information response.write moveto 'drop-down menu navigation Response.write "" End sub '=========================================== ========================== 'showfirstPRV display home, 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 = "" & Btn_First & " = int_totalpage Then str_tmp = Btn_Next & "" & Btn_Last Else Int_NextPage = int_curpage 1 str_tmp = " "& btn_last &"

=================================================== Shownumbtn digital navigation '============================================== ================================================================================================== # 10- 1 end if e_i = (int_curpage / 10) * 10 10 if e_i> int_totalpage life = b_i to e_i if int_curpage = I THEN STR_TMP = STR_TMP & "" & I & " "else str_tmp = str_tmp &"

====================================================== private function function moveto () DIM I, STR_TMP STR_TMP = "Go: