<% '================================================ ==================== 'ShowMorePage ASP version' version huangjm1.00 'code by maomao' Create Date 2004-09-28 'QQ: 5144707' http: // Blog.9cbs.net/maomaoysq '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 by the part of the data paging, and data shows part It 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 paging each page Number of records 'getCurpagenum Returns the number of records Summary This property is read-only' getrs Return the paging RECORDSET This property is read-only 'getConn gets the database connection' getSql gets the query statement 'interface of class' showpage Display Piennium Navigation bar, unique Common Method '############# 类 调 样 样 ######### Create an object' set hjmpage = new showmorepage 'to get the database Connection 'hjmpage.getconn = conn' sql statement 'hjmpage.getsql = "select * from shop_books where newsbook = 1 ORDER BOOKS WHERE News" Sets 20 strokes of each page, default display 10' hjmpage.pageSize = 20 'Display Paging Information, can call any position, you can call multiple' hjmpage.showpage () 'set = hjmpage.getrs ()' Return RECORDSET 'Display Data Start' here You can customize the display mode 'for i = 1 to hjmpage.getcurpagenum 'The number of records of the current page' response.write Left (TRIM (RS ("BookName")), 13) & "..." 'rs.movenext' Next 'Display Data end' S et 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> "Defined Next button Display style const btn_last =" : font>" Defined last a button display style Const XD_Align = "Center" 'define the alignment tab information Const XD_Width = "100%"' custom paging information block size Class ShowMorePage Private Obj_Conn, Obj_Rs, Str_Sql, int_PageSize, Str_Errors, 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) THEN INT_PAGESIZE = ClNG (intValue) Else str_errors = str_errors & "Pagesize is incorrect"
ShowError () End If End Property Public Property Get PageSize If int_PageSize = "" or (not (IsNumeric (int_PageSize))) Then PageSize = 10 Else PageSize = int_PageSize End If End Property '=========== ============================================================================================================================================================================================================= ==== 'getrs attribute' After returning the recording set '======================================================================================================================================================= ============================== Public Property Get GETRS () if INT_TOTALRECORD = 0 THEN CALL getPAGE () if NOT (OBJ_RS. eof and Obj_Rs.BOF) Then if Int_CurPage <> 1 then if Int_CurPage-1 =============================================================================================================================================================2 0 then Call GetPage () If Int_CurPage> Int_TotalPage Then Int_CurPage = Int_TotalPage int_PageNum = Int_TotalRecord- (Int_TotalPage-1) * int_PageSize ElseIf Int_CurPage = Int_TotalPage Then int_PageNum = Int_TotalRecord- (Int_TotalPage-1) * int_PageSize End If GetCurPageNum = int_PageNum End Property '= ============================================================================================================================================================================================================= ============= 'getConn gets the database connection' '============================== =========================================== Public property let getconn (sconn) set obj_conn = sconn endproperty '== ============================================================================================================================================================================================================= ============ 'getSQL get query statement' '======== ============================================================================================================================================================================================================= ====== Public property let getsql (svalue) str_sql = svalue end proty =============================== ============================================100 == ============================================================================================================================================================================================================= ============== ===================================================================================================== Value '===========================================================================================================================================================================300 ================ 'Get the previous value' ======================== f 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 '======================================== ================================ OpenRS opens the data set 'has the home, the previous page, the next page, the last page, and Digital navigation '' =============================================== ======================= Private sub openrs () set obj_rs = server.createObject ("adoDb.recordset") obj_rs.open str_sql, obj_conn, 1, 1 End sub '==================================================================================================================================================================================== ===================== 'getPage creates a paging navigation strip' has a home page, the previous page, the next page, the last page, there are digital navigation '== ============================================== ========================================================================================================================= # Then Str_Errors = Str_Errors & "the total number of records is zero, the data enter" Call ShowError () End If If Int_TotalRecord mod PageSize = 0 Then Int_TotalPage = Int_TotalRecord / int_PageSize Else Int_TotalPage = Int_TotalRecord / int_PageSize 1 End If If Int_CurPage> Int_TotalPage Then Int_CurPage = INT_TOTALPAGE END IF End Sub '============================================= ========================== =============================================================================================================================================== # '' ================================================== ==================== Public SHOWPAGE () DIM STR_TMP STR_URL = getURL () if int_totalRecord = 0 Then Call getPage () '======== ============================================================================================================================================================================================================= == ====== 'Display paging information, each module changes the location of the expiration of the explicit position based on 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 "" End Sub '====================== ====================================================== 'showfirstPRV Display Home 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 & """>" & btn_first & """> "& btn_first & """>
CSTR (int_PRVPAGE) & "" "> & btn_prev &" <"" 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 = " "& btn_next &" "& Btn_last &"
Shownumbtn digital navigation 'Every time you display 10 pages' ======================================= ==========================================0000 N> 1 Then for i = 1 to 10 if m = 1 if m> n THEN EXIT for end if str_tmp = str_tmp & "[" & I & "]" M = M 1 Next End if Shownumbtn = STR_TMP END FUNCTION '========================= ==================================================== 'showpageInfo paging information' Required self-modification '============================================= ===================================, & INT_CURPAGE & "page Trial" & int_totalRecord & "record & int_pagesize & "条 / per page" ShowPageInfo = STR_TMP END FUNCTION '============================================= ====================== 'geturl gets the current URL' is more different, obtains different result '' ========== ============================================================================================================================================================================================================= ======= Private function geturl () DIM Strurl, TMP_URL, I, J, Search_Str, Result_URL Search_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.Srvervariables ("query_string")) if str_Params = "" ten result_url = tmp_url & "? Page =" Else IF InstrRev If j = -1 Then result_url = tmp_URL (str_params, search_str) = 0 Then result_url = tmp_URL & "?" & str_params & "& page =" Else j = InstrRev (str_params, search_str) -2 & "? page =" Else str_lparams = Left (str_params, j) str_rparams = right (str_params, len (str_params) -j-1) if InStr (str_rparams, "&") <> 0 then str_rparams = right (str_rparams, len (str_rparams) -InStr (str_rparams , "&") 1) Else str_rparams = "" end if result_url = tmp_url & "?" & STR_LPARAMS & STR_RPARAMS & "& Page =" END ========================================================================= ========================================4 set the Terminate event. '' ================================================== ==================== Private sub class_terminate obj_rs.close set obj_rs = nothing obj_conn.close set obj_conn = Nothing end sub '=========== ============================================================================================================================================================================================================= ======== 'ShowError error prompt' '=================================== ========================================== private sub showerror () if str_errors <> "" "" " "& Str_errors &") Response.end end if End sub * Class%> <% DIM conn call dbconnect () ##### ######## 类 调 调 样 样 ######### Create object set hjmpage = new showmorepage 'Get database connection hjmpage.getconn = conn' sql statement hjmpage .getsql = "SELECT TOP 6 * from shop_books where newsbook = 1 Order by bookid desc" Sets the record strip data for each page to 5 hjmpage.pageSize = 2 set =