小男孩‘自慰网亚洲一区二区,亚洲一级在线播放毛片,亚洲中文字幕av每天更新,黄aⅴ永久免费无码,91成人午夜在线精品,色网站免费在线观看,亚洲欧洲wwwww在线观看

分享

ASP用于分頁的兩個函數(shù)

 天落雨 2006-01-17
在asp代碼中分頁是有點麻煩的事情,個人在在代碼編寫過程中把分頁代碼寫成了兩個函數(shù),雖然在功能上不是很完善,但對于一般的應用應該是滿足的了。

<%
‘分頁函數(shù)分為兩個函數(shù)
‘CalcPage(totalrec,msg_per_page,currentpage,n,rowcount,PageRs) 分頁計算函數(shù)
‘PageList(ListType,url,querry,Separator,ListLink) 分頁列表函數(shù)

‘分頁計算函數(shù)
‘totalrec 記錄集總數(shù)
‘msg_per_page 每頁顯示的記錄數(shù),在調(diào)用CalcPage時需提前對該變量賦值
‘currentpage 當前頁變量,在調(diào)用CalcPage時需提前對該變量賦值
‘n 總頁數(shù)
‘rowcount 設置每一頁的數(shù)據(jù)記錄數(shù)
‘PageRs 記錄集對象
sub CalcPage(totalrec,msg_per_page,currentpage,n,rowcount,PageRs)
n=0 ‘設置無記錄時頁數(shù)為0
if currentpage="" then currentpage=0
‘PageRs.EOF and PageRs.bof 無記錄
‘Not PageRs.EOF Or Not PageRs.BOF 有記錄
if Not PageRs.EOF Or Not PageRs.BOF then
totalrec=PageRs.recordcount
PageRs.pagesize=msg_per_page
if totalrec mod msg_per_page = 0 then ‘計算總頁數(shù),recordcount:數(shù)據(jù)的總記錄數(shù)
n = totalrec\msg_per_page ‘n:總頁數(shù)
else
n = totalrec\msg_per_page+1
end if
if not isnumeric(currentpage) or currentpage="" then currentpage=1
If currentpage <> "" then
currentpage = cint(currentpage)
end if
if currentpage < 1 then
currentpage = 1
end if
if currentpage*msg_per_page > totalrec and not((currentpage-1)*msg_per_page < totalrec) then
currentPage=1
end if
PageRs.absolutepage = currentpage ‘a(chǎn)bsolutepage:設置指針指向某頁開頭
rowcount = PageRs.pagesize ‘pagesize:設置每一頁的數(shù)據(jù)記錄數(shù)
end if
end sub
%>
<%
‘分頁列表函數(shù)
‘url 跳轉(zhuǎn)的地址
‘querry ?后的參數(shù)
‘Separator 分隔符
‘ListType 分頁類型
‘類型:0 "第一頁 | 前一頁 | 下一頁 | 最后頁"
‘類型:1 "1 | 2 | 3 | 4 | ..........| 下一頁"
‘類型:2 "第一頁 | 前十頁 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 后十頁 | 最后頁"
‘ListLink 鏈接使用的樣式

sub PageList(ListType,url,querry,Separator,ListLink)
if Separator="" then Separator="|"
if ListType="" then ListType="0"
select case ListType
case "0"
response.write"第"&currentpage&"/"&n&"頁  "
response.write"共"&totalrec&"條信息  "
if currentpage <= 1 then
response.write"第一頁 "&Separator&" "
response.write"前一頁 "&Separator&" "
else
response.write"<a href="""&url&"?page=1&"&querry&""" class="""&ListLink&""">第一頁</a> "&Separator&" "
response.write"<a href="""&url&"?page="&currentpage-1&"&"&querry&""" class="""&ListLink&""">前一頁</a> "&Separator&" "
end if
if currentpage = n then
response.write"下一頁 "&Separator&" "
response.write"最后頁 "
else
response.write"<a href="""&url&"?page="&currentpage+1&"&"&querry&""" class="""&ListLink&""">下一頁</a> "&Separator&" "
response.write"<a href="""&url&"?page="&n&"&"&querry&""" class="""&ListLink&""">最后頁</a> "
end if
case "1"
if currentpage < n then
response.write"<a href="""&url&"?page="&currentpage+1&"&"&querry&""" class="""&ListLink&""">下一頁</a> "
else
response.write"下一頁 "
end if
for i=1 to n
if cstr(i)=cstr(currentpage) then
response.write "<b>"&i&"</b>"&" "&Separator&" "
else
response.write"<a href="""&url&"?page="&i&"&"&querry&""" class="""&ListLink&""">"&i&"</a> "&Separator&" "
end if
next

case "2"
PageMerCout=10 ‘每次可翻的最大頁數(shù)
‘取得記錄的最大頁碼段
if n mod PageMerCout=0 then
MaxPageFiled=n\PageMerCout
else
MaxPageFiled=n\PageMerCout+1
end if
‘判斷當前頁所在的頁碼段
if currentpage mod PageMerCout =0 then
CurrPageFiled=currentpage\PageMerCout
else
CurrPageFiled=currentpage\PageMerCout+1
end if
‘取得當前頁碼段的最大頁碼和最小頁碼
MaxPageNo=CurrPageFiled*PageMerCout
MinPageNo=(CurrPageFiled-1)*PageMerCout+1
‘輸出 “第一頁 | 前十頁 |”
if currentpage<=1 then
response.write"第一頁 "&Separator&" "
else
response.write"<a href="""&url&"?page=1&"&querry&""" class="""&ListLink&""">第一頁</a> "&Separator&" "
end if
if CurrPageFiled<=1 then
response.write"前十頁 "&Separator&" "
else
response.write"<a href="""&url&"?page="&MinPageNo-PageMerCout&"&"&querry&""" class="""&ListLink&""">前十頁</a> "&Separator&" "
end if
‘輸出當前頁碼段
for i=MinPageNo to MaxPageNo
if i<=n then
if cstr(i)=cstr(currentpage) then
response.write "<b>"&i&"</b>"&" "&Separator&" "
else
response.write"<a href="""&url&"?page="&i&"&"&querry&""">"&i&"</a> "&Separator&" "
end if
end if
next
‘輸出 “后十頁 | 最后頁”
if CurrPageFiled>=MaxPageFiled then
response.write"后十頁 "&Separator&" "
else
response.write"<a href="""&url&"?page="&MaxPageNo+1&"&"&querry&""" class="""&ListLink&""">后十頁</a> "&Separator&" "
end if
if currentpage>=n then
response.write"最后頁 "
else
response.write"<a href="""&url&"?page="&n&"&"&querry&""" class="""&ListLink&""">最后頁</a> "
end if
end select
end sub
%>

    本站是提供個人知識管理的網(wǎng)絡存儲空間,所有內(nèi)容均由用戶發(fā)布,不代表本站觀點。請注意甄別內(nèi)容中的聯(lián)系方式、誘導購買等信息,謹防詐騙。如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,請點擊一鍵舉報。
    轉(zhuǎn)藏 分享 獻花(0

    0條評論

    發(fā)表

    請遵守用戶 評論公約

    類似文章 更多