?? pagecls.asp
字號:
<%
Const Btn_First="<font face=webdings>9</font>" '定義首頁顯示樣式
Const Btn_Prev="<font face=webdings>7</font>" '定義前*頁顯示樣式
Const Btn_Next="<font face=webdings>8</font>" '定義下*頁顯示樣式
Const Btn_Last="<font face=webdings>:</font>" '定義未頁顯示樣式
Const TD_Align="right" '定義分頁信息對齊方式
Const TD_Width="100%" '定義分頁信息框大小
Class pageShow
Private HY_Conn,HY_Rs,HY_SQL,HY_PageSize,HY_ListNum,str_Error,Int_curpage,Int_totalPage,Int_totalRecord
'============================================
'PageSize 屬性
'設置每一頁的分頁大小
'============================================
Public Property Let PageSize(int_PageSize)
If IsNumeric(Int_Pagesize) Then
HY_PageSize=CLng(int_PageSize)
Else
HY_PageSize=10 '參數有錯,則默認為10
End If
End Property
'得到PageSize 屬性
Public Property Get PageSize
PageSize=HY_PageSize
End Property
'============================================
'ListNum 屬性
'設置分頁數字導航條字數
'============================================
Public Property Let ListNum(int_ListNum)
If IsNumeric(Int_ListNum) Then
HY_ListNum=CLng(Int_ListNum)
Else
HY_ListNum=10 '參數有錯,則默認為10
End If
End Property
'得到ListNum 屬性
Public Property Get ListNum
ListNum=HY_ListNum
End Property
'============================================
'IsReady 屬性
'得到記錄集數組是否可用
'============================================
Public Property Get IsReady
If Int_totalRecord>0 Then
IsReady=true
Else
IsReady=false
End If
End Property
'============================================
'GetRsArray 屬性
'返回分頁后的記錄集數組
'============================================
Public Property Get GetRs()
Set HY_Rs=Server.createobject("adodb.recordset")
HY_Rs.PageSize=HY_PageSize
HY_Rs.Open HY_SQL,HY_Conn,1,1
int_totalRecord=HY_Rs.recordcount
If Not HY_Rs.eof Then
If Int_curpage > HY_Rs.PageCount Then Int_cutpage = HY_Rs.PageCount
HY_Rs.AbsolutePage=int_curpage
End If
Set GetRs=HY_Rs '返回記錄
End Property
'=====================================
'GetConn 得到數據庫連接'
'=====================================
Public Property Let GetConn(obj_Conn)
Set HY_Conn=obj_Conn
End Property
'====================================
'GetProcName 得到存儲過程名'
'====================================
Public Property Let GetSQL(str_sql)
HY_SQL=str_sql
End Property
'=====================================
'Class_Initialize 類的初始化
'初始化當前頁的值'
'=====================================
Private Sub Class_Initialize
'============================
'設定一些參數的黙認值
'============================
HY_PageSize=10 'pagesize屬性,默認為10
HY_ListNum=10 '數字導航條默認顯示10個數字
'如:1 2 3 4 5 ...... 10
'============================
'獲取當前頁的值
'============================
Int_curpage=trim(request("page"))
If Int_curpage="" Then
Int_curpage=1
ElseIf not(IsNumeric(Int_curpage)) Then
int_curpage=1
ElseIf CLng(Int_curpage)<1 Then
int_curpage=1
Else
Int_curpage=CLng(Int_curpage)
End If
End Sub
'==============================
'得到當前頁數
'==============================
Public Property Get curPage
curPage=Int_curpage
End Property
'===========================================
'pageNav 創建分頁導航條
'有首頁、前一頁、下一頁、末頁、還有數字導航'
'===========================================
Public Sub pageNav()
Dim str_tmp,p,Url
Url=GetUrl
If int_totalRecord Mod HY_PageSize=0 Then
int_TotalPage= int_totalRecord \ HY_PageSize
Else
int_TotalPage= int_totalRecord \ HY_PageSize+1
End If
If Int_curpage>int_Totalpage Then
int_curpage=int_TotalPage
End If
If Int_curPage-1 Mod HY_ListNum=0 Then
p=(Int_curPage-1) \ HY_ListNum
Else
p=(Int_curPage-1) \ HY_ListNum
End If
'===========================================
'顯示分頁信息,各個模塊根據自己要求更改顯求位置
'===========================================
response.write "<table border=0 width="&TD_Width&"><tr><td align="&TD_Align&">"
str_tmp=pageNavInfo(Url,p)
response.write str_tmp
response.write "</td></tr></table>"
End Sub
'==========================================
'pageNavInfo 分頁信息
'更據要求自行修改'
'==========================================
Private Function pageNavInfo(Url,p)
Dim str_tmp,i
'str_tmp="頁次:"&int_curpage&"/"&int_totalpage&"頁 共"&int_totalrecord&"記錄 "&HY_PageSize&"條/頁 "
'str_tmp="頁次:"&int_curpage&"/"&int_totalpage&"頁 "&HY_PageSize&"條/頁 "
' 顯示首頁、前**頁
'===============
If Int_curPage=1 Then
str_tmp=str_tmp&Btn_First&" "
Else
str_tmp=str_tmp & "<a href='"&Url&"1' title=首頁>"&Btn_First&"</a> "
End If
If p*HY_ListNum>0 Then str_tmp=str_tmp & "<a href='"&Url&(p*HY_ListNum)&"' title=上"&HY_ListNum&"頁>"&Btn_Prev&"</a> "
' 數字導航
'=========
For i=p*HY_ListNum+1 To (P+1)*HY_ListNum
If i=Int_curPage Then
str_tmp=str_tmp&"<font color=red>"&i&"</font> "
Else
str_tmp=str_tmp&"<a href='"&Url&i&"'>"&i&"</a> "
End If
If i=int_TotalPage Then Exit For
Next
'ShowNextLast 下**頁、末頁
'=========================
If i<int_TotalPage then str_tmp=str_tmp&"<a href='"&Url&i&"' title=下"&HY_ListNum&"頁>"&Btn_Next&"</a> "
If Int_curPage=int_TotalPage Then
str_tmp=str_tmp&Btn_Last
Else
str_tmp=str_tmp&"<a href='"&Url&int_TotalPage&"' title=尾頁>"&Btn_Last&"</a>"
End if
str_tmp=str_tmp & " 頁次:"&Int_curPage&"/"&int_TotalPage&" 共"&int_TotalRecord&"個記錄 "&HY_PageSize&"個/頁"
pageNavInfo=str_tmp
End Function
'=========================================
'GetURL 得到當前的URL參數
'更據URL參數不同,獲取不同的結果'
'注意,此方法只能抓取到GET方法提交的參數
'=========================================
Private Function GetURL()
Dim j,result_url,str_params
Const search_str="page="
str_params=Request.ServerVariables("QUERY_STRING")
If str_params="" Then
result_url="?page="
Else
If InstrRev(str_params,search_str)=0 Then
result_url="?" & str_params &"&page="
Else
j=InstrRev(str_params,search_str)-2
If j=-1 Then
result_url="?page="
Else
str_params=Left(str_params,j)
result_url="?" & str_params &"&page="
End If
End If
End If
GetURL=result_url
End Function
'=======================================
' 設置 Terminate 事件。'
'=======================================
Private Sub Class_Terminate
HY_Rs.Close
Set HY_Rs=Nothing
End Sub
'=======================================
'ShowError 錯誤提示'
'=======================================
Private Sub ShowError()
If str_Error <> "" Then
Response.Write("<font color=""#FF0000""><br><b>" & SW_Error & "</font>")
Response.End
End If
End Sub
End class
%>
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -