一段通用ASP分页过程

一段通用ASP分页过程

过程主要参数 ByRef PageCount,RecordCount,CurrentPage,PageSize,LinkFile
 

具体参数介绍

ByRef PageCount
总页数

RecordCount
记录数

CurrentPage
当前页

PageSize
每页显示数

LinkFile
连接地址

过程代码

 

ASP/Visual Basic 代码
 
  1. <%   
  2. Function ShowPage(ByRef PageCount,RecordCount,CurrentPage,PageSize,LinkFile)       
  3.     Dim Retval,J,StartPage,EndPage       
  4.     If (RecordCount Mod PageSize)=0 Then      
  5.         PageCount=RecordCount \ PageSize       
  6.     Else        
  7.         PageCount=RecordCount \ PageSize+1       
  8.     End If      
  9.     If PageCount<=0 Then PageCount=1       
  10.     If CurrentPage="" Then CurrentPage=1 else CurrentPage=CInt(CurrentPage)       
  11.     Retval=Retval & "<table Width='100%' border='0' cellspacing='0' cellpadding='0' bgcolor='#D7E4F7'>"      
  12.     Retval=Retval & "<tr>"      
  13.     Retval=Retval & "<td>"      
  14.     If CurrentPage=1 Then                     
  15.         Retval=Retval & "&nbsp;<font style='color:#000000'>首页</font> | <font style='color:#000000'>前页</font> | "        
  16.     Else      
  17.         Retval=Retval & "<a href='" & LinkFile & "Page=1'>首页</a> | <a href='" & LinkFile & "Page=" & CurrentPage - 1 & "'>前页</a> | "      
  18.     End If      
  19.     If  CurrentPage=PageCount Then                    
  20.         Retval=Retval & "<font style='color:#000000'>后页</font> | <font style='color:#000000'>末页</font>"      
  21.     Else      
  22.         Retval=Retval & "<a href='" & LinkFile & "Page=" & CurrentPage + 1 & "'>后页</a> | <a href='" & LinkFile & "Page=" & PageCount & "'>末页</a>"      
  23.     End if       
  24.     If RecordCount>0 Then      
  25.         Retval=Retval & " | <b>"&CurrentPage&"</b>页/<b>"&CInt(PageCount)&"</b>页 | 共<b>"&RecordCount&"</b>条记录"      
  26.     End If      
  27.     Retval=Retval & "<td align='right'>"      
  28.     StartPage = Page-3       
  29.     EndPage = Page+3       
  30.     If StartPage<=0 Then      
  31.         StartPage=1       
  32.     ElseIf StartPage>1 Then        
  33.         Retval=Retval & " <a href='" & LinkFile & "Page=1' style='font-family:webdings' title='首页'>9</a>"      
  34.         Retval=Retval & " ... "      
  35.     End If             
  36.     If EndPage>PageCount Then EndPage=PageCount       
  37.     For J = StartPage to EndPage       
  38.         If J = Page Then      
  39.             Retval = Retval & " <font color=#999999>" & J & "</font>"      
  40.         Else      
  41.             Retval = Retval & " <a href='" & LinkFile & "Page=" & J & "'>" & J & "</a>"      
  42.         End If      
  43.     Next      
  44.     If EndPage < PageCount Then Retval= Retval & " ... <a href='" & LinkFile & "Page=" & PageCount & "' style='font-family:webdings' title='末页'>:</a>"      
  45.     Retval=Retval & "</td>"      
  46.     Retval=Retval & "</tr>"      
  47.     Retval=Retval & "</table>"      
  48.     ShowPage=Retval       
  49. End Function      
  50. %>  

如果你在使用过程中遇到什么问题,欢迎把您的反馈信息告诉我!



评论: 0 | 引用: 0 | 查看次数: 721 | 返回顶部
[2012-1-31 16:24:33 ]

[2012-1-27 17:58:23 ]
valtrex eye colchicine %-PPP
发表评论
昵 称:  
验证码:  
内 容: