Super ASP big paging

xiaoxiao2021-03-06  40

<% '=========================================== ======= ShowMorePage ASP version? Version huangjm1.00'code by maomao'create date 2004-09-28' qqq: 5144707'http: //blog.9cbs.net/maomaoysq'write for my lover: huangjm 'This program can be used free, modify, but please Retaining the above information '' Function 'This program is mainly packaged for 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 for the current page This property is read-only' getrs Return through the paging RECORDSET This property Read-only 'getConn gets the database connection' getSql gets the query statement 'interface of class'showpage Distributes the page navigation bar, the only common method' ################################################################################################################## ########### Create 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 "Set the record strip data for each page to 20, the default display 10 'hjmpage.pageSize = 20' display paging information, can be called in any position, you can call multiple 'hjmpage.showpage ()' set RS = hjmpage.getrs () 'Returns 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 "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 =" : < / font> " 'defines a button display style last Const XD_Align =" Center "' define the alignment tab information Const XD_Width =" 100% " 'custom paging information block size Class ShowMorePagePrivate Obj_Conn, Obj_Rs, Str_Sql, int_PageSize, Str_Errors, Int_CurPage , Str_url, int_totalpage, int_totalRecord

'================================================== PageSize Properties 'Settings Each page Size' ======================================== ========= Public Property Let PageSize (intvalue) If IsNumeric (intvalue) Thenint_PageSize = CLng (intvalue) ElseStr_Errors = Str_Errors & "PageSize parameter is incorrect" ShowError () End IfEnd PropertyPublic Property Get PageSizeIf int_PageSize = " "OR (not (ISNUMERIC (ISNUMERIC (int_pagesize)) Thenpagesize = 10 elsendationsize = int_pagesizend ingnd 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) Thenif Int_CurPage <> 1 thenif Int_CurPage-1

'================================================== GetCurpagenum Properties 'Returns the number of records 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' '============================== ================== PUBLIC Property Let getConn (sconn) set obj_conn = SCONNEND PROPERTY

'================================================== GetSQL get query statement '' ============================================ ==== Public Property Let GetSQL (Svalue) STR_SQL = SVALUEEND Property

'================================================== The initialization of the Class_Initialize class' initializes the value of the current page '' ====================================== ========== Private sub class_initialize '========================' Sets some parameters 黙 recognition value '== =====================================================================================================================================================================================================================================================31 =========== 'Get the previous value' ======================== f Request ("Page") = "" ThenInt_CurPage = 1ElseIf not (IsNumeric (request ( "page"))) ThenInt_CurPage = 1ElseIf CInt (Trim (request ( "page"))) <1 ThenInt_CurPage = 1ElseInt_CurPage = CInt (Trim (request ( "page"))) END IF

End sub '==================================================================================================================================================================================== = 'OpenRS Open Data Set' There is a home page, previous page, next page, last page, there is a digital navigation '======================== ==========================================================================================================================================================00 1,1end sub '============================================= === 'getPage creates a paging navigation bar' has a home page, the previous page, the next page, the last page, there is a digital navigation '==================== ================================================================================================================== Obj_Rs.RecordCountIf Int_TotalRecord <= 0 ThenStr_Errors = Str_Errors & "the total number of records is zero, the data enter" Call ShowError () End IfIf Int_TotalRecord mod PageSize = 0 ThenInt_TotalPage = Int_TotalRecord / int_PageSizeElseInt_TotalPage = Int_TotalRecord / int_PageSize 1End If If Int_CurPage> Int_TotalPage ThenInt_CurPage = INT_TOTALPAGEEND IFEND SUB

'================================================== ShowPage Creating Page Navigation Board 'has a homepage, previous page, next page, 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 Change the location based on yourself '========================================== ====== response.write "" str_tmp = ShowFirstPrvresponse.write str_tmpstr_tmp = showNumBtnresponse.write str_tmpstr_tmp = ShowNextLastresponse.write str_tmpstr_tmp = ShowPageInforesponse.write str_tmp response.write "" End Sub

'================================================== ShowfirstPRV Show home, previous page 'www.knowsky.com' ===================================== ============ Private Function ShowFirstPrv () Dim Str_tmp, int_prvpageIf Int_CurPage = 1 Thenstr_tmp = Btn_First & "" & Btn_PrevElseint_prvpage = Int_CurPage-1str_tmp = "" & btn_prev & "<" end ifshowfirstprv = str_tmpend function

'================================================== ShowNextlast Next, last page '' ========================================== ======= Private Function ShowNextLast () Dim str_tmp, int_NextpageIf Int_CurPage> = Int_TotalPage Thenstr_tmp = Btn_Next & "" & Btn_LastElseInt_NextPage = Int_CurPage 1str_tmp = "" & btn_last & "

'================================================== Shownumbtn Digital Navigation 'Every time you display 10 pages' ======================================== ======== Private 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 forends ifstR_TMP = Str_TMP & "[" & I & "]" M = M 1NEXTEND IFSHOWNUMBTN = STR_TMPEND FUNCTION

'================================================== ShowPageInfo Paging Information 'More demands to modify' ======================================== ======== Private 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 current URL 'is more dependent on the URL parameters, get different results' ===================================== =========== Private function getURL () DIM Strurl, Tmp_URL, I, J, Search_Str, Result_urlSearch_Str = "Page =" StrURL = Request.serverVariables ("URL") Strurl = Split (Strull, " / ") 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 Ifend ifden = result_urlend function

'================================================== Set 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 surund suend class%>

<% DIM conncall dbconnect ()

'####################################################################################################################### = conn'sql statement hjmpage.getsql = "SELECT TOP 6 * from shop_books where newsbook = 1 ORDER BY BOOKID DESC" "Sets each page record strip data to 5 hjmpage.pagesize = 2set = hjmpage.getrs () ' Returns RecordSet 'Display Paging Information, this method can be, after SET RS = hjmpage.getrs (), can be called in any position, you can call multiple hjmpage.showpage () display data response.write ("<" For i = 1 to hjmpage.getcurpagenum 'The number of records of the current page' here can customize the display mode%>

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

New Post(0)