<%
'==================================================== ==================
'ShowMorePage ASP version
'Version Huangjm1.00
'Code by Maomao
'Create Date 2004-09-28
'QQ: 5144707
'
http://blog.9cbs.net/maomaoysq/archive/2004/09/29/120856.aspx
'Write for my lover: huangjm
'This program can be used free of charge, but please keep the above information' '' Function 'This program is mainly packaged in the part of the data paging, and the data display is completely customized by the user,' Supports multiple parameters of the URL: http : //www.***.com/***.asp? aa = 1 & Page = 9 & BB = 2 '' 'paramers:' PapGesize Definition Points Each page Records' getCurPageNum Returns the number of records of the current page This property Read-only 'getrs returns the paging RECORDSET This property is read-only' getConn gets the database connection 'getSql gets query statement' interface of class'showpage Distributes the page navigation bar, the unique common method '########## ### 类 调 样 样 ########## Create an object 'set hjmpage = new showmorepage' Get database connection 'hjmpage.getconn = conn'sql statement' hjmpage.getsql = "Select * from shop_books where newsbook = 1 ORDER BY BOOKID DESC" 'Sets the record strip data for each page to 20, the default display 10' hjmpage.pageSize = 20 'display paging information, can be called anywhere, Call multiple 'hjmpage.showpage.GeTRs ()' Return Recordset ()
'Display Data Start' This can be customized in the display mode 'for i = 1 to hjmpage.getCurPagenum' The number of records of the current page 'Response.write Left (TRIM (RS ("BookName"), 13) & ".. .. "'rsmovenext'next' Display data end 'set hjmpage = nothing' ############################################################################################################################################################################################################################################################## ### '============================================== ===================== CONST BTN_FIRST = " 9 font> "Defines the first page button Display style const BTN_PREV = " 3 font> "Define Previous Page button Display Style const btn_next =" 4 font>" Under Definition One page button Display style const btn_last = ": font> "Defines the last page button Display style const xd_align =" center "Defines the paging information alignment const XD_WIDTH =" 100 % "Defines the Size Page Information Box Size
Class showmorepageprivate obj_conn, obj_rs, str_sql, int_pagesize, str_erro, int_curpage, str_URL, int_totalpage, int_totalRecord
'==================================================== ================ 'PageSize property' Sets the page size of each page '====================== ==================================================== Public Property Let PageSize (intValue) If IsNumeric (intvalue) Thenint_PageSize = CLng (intvalue) ElseStr_Errors = Str_Errors & "parameter PageSize incorrect" ShowError () End IfEnd PropertyPublic Property Get PageSizeIf int_PageSize = "" or (not (IsNumeric (int_PageSize))) ThenPageSize = 10 ElsePageSize = INT_PAGESIZEEND IFEND Property
'==================================================== ================ 'getRs attribute' After returning the paging set '======================== =================================================== f INT_TOTALRECORD = 0 then Call GetPage () If not (Obj_Rs.eof and Obj_Rs.BOF) thenif Int_CurPage <> 1 thenif Int_CurPage-1 '==================================================== ================ 'getCurpagenum property' Returns the number of record sets of the current page '====================== ==================================================== Public Property Get getCurpagenum () DIM int_PageNumint_PageNum = int_PageSizeif Int_TotalRecord = 0 then Call GetPage () If Int_CurPage> Int_TotalPage ThenInt_CurPage = Int_TotalPageint_PageNum = Int_TotalRecord- (Int_TotalPage-1) * int_PageSize ElseIf Int_CurPage = Int_TotalPage Thenint_PageNum = Int_TotalRecord- (Int_TotalPage-1) * int_PageSize End IfGetCurPageNum = int_PageNumEnd Property '==================================================== =============== 'getConn gets the database connection' '============================ ==========================================================================================================================3 ============================================================================================================================================================================================================= ============= 'getSQL get query statement' '=============================== =========================================== Public property let getsql (svalue) str_sql = svalueend property '==================================================== =======================================================================================================================================================================================================================================3 ======================================================= private sub class_initialize ' ======================== 'Set some parameters' 黙 recognition' ================== ======== INT_PAGESIZE = 10 'Set the default value of the paging is 10INT_TOTALRECORD = 0' ======================== 'Get the current Face value '======================== ========= "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" " )))) ") <1 ten_curpage = 1ELSEINT_CURPAGE = CINT (TRIM (" page ")))")))) "))))" =================== ================================================ 'OpenRS opens the data set' has the home page, the previous one Page, next page, the last page, there is a digital navigation '' =================================== ==================================================================================================================================================================================== # "= ) Obj_rs.open str_sql, obj_conn, 1,1end sub '====================================== ================================================================================================================ Page, there are digital navigation '' ========================================== ======================================================================================00 Recordcountif int_totalRecord <= 0 THENSTR_ERRORS = STR_ERRORS & "Total number of records is zero, please enter data" call showerror () end ifif int_totalRecord mod pagesize = 0 thrAlpage = INT_TOTALRECORD / INT_PAGESIZEELSEINT_TOTALPAGE = INT_TOTALRECORD / INT_PAGESIZE 1END IF INT_CURPAGE> INT_TOTALPAGE THENINT_CURPAGE = INT_TOTALPAGEEND IFEND 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 SHOWPAGE () DIM STR_TMPSTR_URL = getURL () if int_totalRecord = 0 Then Call getPage () '=============== ============================================================================================================================================================================================================= = 'Display paging information, each module changes the location of the visuality based on yourself' ================================== ================================= Response.write "" str_tmp = showfirstprvresponse.write str_tmpstr_tmp = ShownumbtnResponse.write str_tmpstr_tmp = shownextlastResponse .write str_tmpstr_tmp = ShowPageInfoSponse.write str_tmp response.write "" End sub '========================================= ============================== 'showfirstPRV display home, the previous page' '========== ============================================================================================================================================================================================================= ========= Private Function ShowFirstPrv () Dim Str_tmp, int_prvpageIf Int_CurPage = 1 Thenstr_tmp = Btn_First & "" & Btn_PrevElseint_prvpage = Int_CurPage-1str_tmp = " "& Btn_first &" "& btn_prev &" "" end ifshowfirstprv = str_tmpend function '==================================================== =================== 'Shownextlast Next, the last page' '' ============================================================================================================================================================================ ======================================================== pVate function ShowNextLast () Dim str_tmp, int_NextpageIf Int_CurPage> = Int_TotalPage Thenstr_tmp = Btn_Next & "" & Btn_LastElseInt_NextPage = Int_CurPage 1str_tmp = "" & Btn_Next & " A> "& btn_last &"
'==================================================== =================== 'shownumbtn digital navigation' Every time I display 10 page '==================================================================================================================================================================== ========================================================== pVate Function shownumbtn () DIM I, STR_TMP, M, NM = INT_CURPAGE - 4N = INT_TOTALPAGEIF N> 1 Thenfor I = 1 to 10IF M <1 THEN M = 1 IF M> n THENEXIT Forend ifstr_tmp = STR_TMP & "[ & I & "]" M = M 1NEXTEND IFSHOWNUMBTN = STR_TMPEND FUNCTION '==================================================== =================== 'showpageinfo paging information' Moreover to modify '' ================================================================================================================================================================= ========================================================== pVate Function ShowPageInfo () Dim str_tmpstr_tmp = "page:" & Int_CurPage & "/" & Int_TotalPage & "total" & Int_TotalRecord & "records" & int_PageSize & "article / page" ShowPageInfo = str_tmpEnd Function '============ ============================================================================================================================================================================================================= ==== 'getURL gets the current URL' is different from the URL parameters, gets different result '' =========================== ======================================== Private Function GetURL () Dim strUrl, tmp_URL, i, j, search_str, result_urlsearch_str = "page =" strUrl = Request.ServerVariables ( "URL") strUrl = split (strUrl, "/") i = UBound (strUrl, 1) tmp_URL = strUrl (i) 'get the current page file name str_params = Trim (Request.ServerVariables ( "QUERY_STRING")) If str_params = "" Thenresult_url = tmp_URL & "? page =" ElseIf InstrRev (str_params, search_str) = 0 Thenresult_url = tmp_URL & "?" & str_params & "& page =" Elsej = InstrRev (str_params, search_str) -2If j = -1 Thenresult_url = tmp_URL & "? page =" Elsestr_lparams = Left (str_params, j) str_rparams = right (str_params, len (str_params) -j-1) if InStr (str_rparams, "&") <> 0 thenstr_rparams = right (str_rparams, len (str_rparams) -InStr (str_rparams, "&") 1) elsestr_rparams = "" end ifresult_url = tmp_URL & "?" & str_lparams & str_rparams & "& page =" End ifend ingnd ifdenurl = result_urlend function '==================================================== =================== 'Sets the Terminate event. '' ================================================== ==================== Private sub class_terminate obj_rs.closset Obj_rs = NothingObj_conn.closset obj_conn = Nothingend Sub '============== ============================================================================================================================================================================================================= ==== 'ShowError error prompt' '====================================== ====================================== Private Sub showError () if str_errors <> "" "" "& str_errors &" ") Response.Endend IFEND SUBEND Class%>