ASP classic paging class

xiaoxiao2021-03-06  54

============================================================================================================================================================================================================= =================== 'XDOWNPAGE ASP version' version 1.00'Email:

ZYKJ_2000@163.net

'BBS:

http://bbs.513soft.net/

'This program can be used free, modify, I hope my program can bring convenience to your work', but please keep the above information '' program characteristics' This program is mainly packaged by the part of the data sheet, and the data display unit The copies are completely customized by the user, 'Support URL multiple parameters' 'use instructions' program parameter description 'PapGesize defined Paging Each page records' getrs Return through the paging RECORDSET This property is read-only 'getConn gets database connection' getSql gets Query Statement 'Program Method Description' ShowPage Displays the page navigation bar, the only common method '' example: '

'

'Contains file' 'set mypage = new xdown.getconn = conn' Get database connection 'mypage.getsql = "select * from productinfo order by id ASC"' mypage.pagesize = 5 'Setting each page The record strip data is 5 'SET RS = mypage.getrs ()' Returns RecordSet 'mypage.showpage ()' Shows Pedimentation Information, this method can be called after SET RS = mypage.getrs (), can be called Multiple 'for i = 1 to mypage.pagesize' The next operation is to operate with a normal Recordset object. 'If not xi ee' This tag is to prevent the last page from overflow 'response.write RS (0 ) & "", You can customize the display mode 'rsmovenext' else 'exit for' end if 'next' ===================== =============================================================== consT btn_first = "9" Defined the first page button Display style const btn_prev = "3" 'Defined Previous Page button Display Style const btn_next = "4" Defined 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 Const XD_Height = "20" Class XdownpagePrivate XD_PageCount, XD_Conn, XD_Rs, XD_SQL, XD_PageSize, Str_errors, int_curpage , str_url, int_totalpage, int_totalRecord

'==================================================== ================ 'PageSize property' Sets the page 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 & "parameter PageSize incorrect" ShowError () End IfEnd PropertyPublic Property Get PageSize If XD_PageSize = "" or (not (IsNumeric (XD_PageSize))) Then PageSize = 10 else pagesize = xd_pagesize end ifend property

'==================================================== ================ 'getRs attribute' After returning the paging 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 end if set getrs = xd_rsend print

'==================================================== =============== 'getConn gets the database connection' '============================ =================================================3 ============================================================================================================================================================================================================= ============= 'getSQL get query statement' '=============================== =========================================== pic = STR_SQLEND PROPERTY

'==================================================== =======================================================================================================================================================================================================================================3 ======================================================= private sub class_initialize ' ======================== 'Set some parameters' 黙 recognition' ================== ======== xd_pagesize = 10 'Set the default value of the paging is 10' ======================== 'Get the front Value '============================================================================================================================================================================================================================================================== # )))) = 1 elseif cint (TRIM (Request ("page"))) <1 THEN INT_CURPAGE = 1 else int_curbage = cint (TRIM (Request ("page")) End If End Sub

'==================================================== =================== 'showpage creates a paging navigation bar' has a home page, the previous page, the next page, the last page, there is a digital navigation '==== ============================================================================================================================================================================================================= ============== Public Sub 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_totalRecordint_totalpage = 1

Else

IF INT_TOTALRECORD MOD PAGESIZE = 0 THEN

INT_TOTALPAGE = INT (int_totalRecord / xd_pagesize * -1) * - 1

Else

INT_TOTALPAGE = INT ((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, each module changes the location according to yourself

'==================================================== =============================== Response.write "

"Str_tmp = ShowFirstPrv response.write str_tmp str_tmp = showNumBtn response.write str_tmp str_tmp = ShowNextLast response.write str_tmp str_tmp = ShowPageInfo response.write str_tmp 'Response.write" "ShowGoto response.write"

"END SUB

'==================================================== =================== 'showfirstPRV Display Home, the previous page' '======================================================================================================================================================================== ======================================================== pVate 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 & "" & Btn_Prev & "" End If ShowFirstPrv = str_tmpEnd Function

'==================================================== =================== 'Shownextlast Next, the last page' '' ============================================================================================================================================================================ ======================================================== pVate 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 = "" & Btn_Next & "" & Btn_Last & ""

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 & "[" & I & "]"' Next 'Shownumbtn = STR_TMP' 'end function' =============== ============================================================================================================================================================================================================= === 'ShownumbTn Modified Digital Navigation' ======================================= ===========================================================================================================================================================================================================

4 THEN IF INT_CURPAGE 2START_PAGE = INT_CURPAGE-2

END_PAGE = INT_CURPAGE 2

Else

START_PAGE = INT_TOTALPAGE-4

END_PAGE = INT_TOTALPAGE

END IF

Else

START_PAGE = 1

IF INT_TOTALPAGE> 5 THEN

END_PAGE = 5

Else

END_PAGE = INT_TOTALPAGE

END IF

END IF

For i = start_page to end_page

STR_TMP = STR_TMP & "

"& I &"] "Next Shownumbtn = STR_TMPEND FUNCTION

'==================================================== =================== 'Showgoto page jump' '' ======================================================================================================================================= ====================================================== private function showgoto () DIM m_item '================================================ ========= 'Write the returned URL parameters in the hidden domain, so that the parameters continue to pass' ====================== ====================================================28 = 0 THEN 'Remove the value of "Page" from the parameter "" "end if next' =========================== ==================

============ Response.write "Go to the inquiry:" response.write "page" end function "==================== ================================================= =PageInfo Page information 'is more demanded to modify' '======================================== ========================================14 ] [Total "& INT_TOTALRECORD &" Bill] ["& XD_PageSize &" Bar / Page] "ShowPageInfo = STR_TMPEND FUNCTION

'==================================================== ================== 'After modification, the function of the current URL parameter' codeing by redsun '================= ============================================================================================================================================================================================================= == Private Function GetUrl () Dim ScriptAddress, M_ItemUrl, M_item ScriptAddress = CStr (Request.ServerVariables ( "SCRIPT_NAME")) & "?" 'get current address If (Request.QueryString <> "") Then M_ItemUrl = "" For Each M_Item in Request.QueryString if INSTR ("Page", M_Item) = 0 THEN M_ITEMURL = M_Item.url & m_Item & "=" & Server.urlencode ("& M_Item &") & "&" End if Next Scriptaddress = scriptaddress & m_itemurl 'acquired parameter Address End if geturl = scriptaddress & "Page =" End Function

'==================================================== =================== 'Sets the Terminate event. '==================================================== ================================================================================================================================================================================================ =================================================== ShowError error prompt '=============================================== ============================== Private Sub showError () if str_error <> "" "" "" "& sw_error &") response.end end IFEND SUBEND CLASS

转载请注明原文地址:https://www.9cbs.com/read-114121.html

New Post(0)