第五个<%'===================================================================='= ASP分页类'= Copyright (c) 2006 - 2007 Fhuoyun All Rights Reserved.'=-------------------------------------------------------------------'= 最后更新:fhuoyun'= 最后日期:下午 05:13 2006-12-13'====================================================================
Class cls_pagelist
'************************************************************************************* '页面数据 '************************************************************************************* Public Function CutPageList(iSQL,iCurrentPage,iPageSize) On Error Resume Next Err.Clear
Set Rs=Server.CreateObject("adodb.recordSet") Rs.Open iSQL,Conn,1,1 If Not rs.Eof And Not rs.bof Then Rs.AbsolutePosition=Rs.AbsolutePosition+((Abs(iCurrentPage)-1)*iPageSize) CutPageList=Rs.GetRows(iPageSize) Else CutPageList="" End If Rs.Close Set Rs=Nothing If Err Then Response.clear ErrMsg="在执行以下语句3:<br>" ErrMsg=ErrMsg&" <font color=800000>"&iSQL&"</font><br>" ErrMsg=ErrMsg&"时,发生以下错误1:<br>" ErrMsg=ErrMsg&" <font color=800000>"&Err.Description&"</font>" Response.Write ErrMsg End If End Function
'************************************************************************************* '页脚分页 '************************************************************************************* Public Function PageList (PageCount,iCurrentPage,FieldName,FieldValue) Dim Url Dim PageRoot Dim PageFoot Dim OutStr Dim i If IsArray(FieldName) And IsArray(FieldValue) Then Dim page_i For page_i=0 to Ubound(FieldName) Url=Url&"&"&Cstr(FieldName(page_i))&"="&Cstr(FieldValue(page_i)) Next End If
If CLng(iCurrentPage)<=0 Then iCurrentPage=1 ElseIf CLng(iCurrentPage)>CLng(PageCount) Then iCurrentPage=PageCount End if If iCurrentPage-2<=1 Then PageRoot=1 Else PageRoot=iCurrentPage-2 End If If iCurrentPage+2>=PageCount Then PageFoot=PageCount Else PageFoot=iCurrentPage+2 End If OutStr="<div id=""pageList""><span class=""list"">共 "&PageCount&" 页</span> " If iCurrentPage<=1 Then OutStr=OutStr&"<span class=""hidden"">«</span> " OutStr=OutStr&"<span class=""hidden""><</span> " Else OutStr=OutStr&"<span class=""first""><a href=""?page=1" OutStr=OutStr&Url OutStr=OutStr&""" title=""首页"">«</a></span> " OutStr=OutStr&"<span class=""list""><a href=""?page="&iCurrentPage-1 OutStr=OutStr&Url OutStr=OutStr&""" title=""上页""><</a></span> " End If For i=PageRoot To PageFoot If i=Cint(iCurrentPage) Then OutStr=OutStr&"<span class=""current"">"&i&"</span> " Else OutStr=OutStr&"<span class=""list""><a href=""?page="&Cstr(i) OutStr=OutStr&Url OutStr=OutStr&""">"&i&"</a></span> " End If If i=PageCount Then Exit For Next
If Cint(iCurrentPage)=Cint(PageCount) Then OutStr=OutStr&"<span class=""hidden"">></span> " OutStr=OutStr&"<span class=""hidden"">»</span> " Else OutStr=OutStr&"<span class=""list""><a href=""?page="&iCurrentPage+1 OutStr=OutStr&Url OutStr=OutStr&""" title=""下页"">></a></span> " OutStr=OutStr&"<span class=""last""><a href=""?page="&PageCount OutStr=OutStr&Url OutStr=OutStr&""" title=""尾页"">»</a></span> " End If If PageCount > 0 Then OutStr=OutStr&" <input type=""text"" size=""3"" value="""&iCurrentPage&""" onmouseover=""this.focus();this.select()"" id=""PGNumber"" /> <input type=""button"" value=""GO"" onclick=""if (document.getElementById('PGNumber').value>0 && document.getElementById('PGNumber').value<="&PageCount&"){window.location='?page='+document.getElementById('PGNumber').value+'"&Url&"'}"" />" End If
OutStr = OutStr & "</div>"
PageList=OutStr End Function
End Class%>