一段通用ASP分页过程
过程主要参数 ByRef PageCount,RecordCount,CurrentPage,PageSize,LinkFile
具体参数介绍
ByRef PageCount
总页数
RecordCount
记录数
CurrentPage
当前页
PageSize
每页显示数
LinkFile
连接地址
过程代码
ASP/Visual Basic 代码
- <%
- Function ShowPage(ByRef PageCount,RecordCount,CurrentPage,PageSize,LinkFile)
- Dim Retval,J,StartPage,EndPage
- If (RecordCount Mod PageSize)=0 Then
- PageCount=RecordCount \ PageSize
- Else
- PageCount=RecordCount \ PageSize+1
- End If
- If PageCount<=0 Then PageCount=1
- If CurrentPage="" Then CurrentPage=1 else CurrentPage=CInt(CurrentPage)
- Retval=Retval & "<table Width='100%' border='0' cellspacing='0' cellpadding='0' bgcolor='#D7E4F7'>"
- Retval=Retval & "<tr>"
- Retval=Retval & "<td>"
- If CurrentPage=1 Then
- Retval=Retval & " <font style='color:#000000'>首页</font> | <font style='color:#000000'>前页</font> | "
- Else
- Retval=Retval & "<a href='" & LinkFile & "Page=1'>首页</a> | <a href='" & LinkFile & "Page=" & CurrentPage - 1 & "'>前页</a> | "
- End If
- If CurrentPage=PageCount Then
- Retval=Retval & "<font style='color:#000000'>后页</font> | <font style='color:#000000'>末页</font>"
- Else
- Retval=Retval & "<a href='" & LinkFile & "Page=" & CurrentPage + 1 & "'>后页</a> | <a href='" & LinkFile & "Page=" & PageCount & "'>末页</a>"
- End if
- If RecordCount>0 Then
- Retval=Retval & " | <b>"&CurrentPage&"</b>页/<b>"&CInt(PageCount)&"</b>页 | 共<b>"&RecordCount&"</b>条记录"
- End If
- Retval=Retval & "<td align='right'>"
- StartPage = Page-3
- EndPage = Page+3
- If StartPage<=0 Then
- StartPage=1
- ElseIf StartPage>1 Then
- Retval=Retval & " <a href='" & LinkFile & "Page=1' style='font-family:webdings' title='首页'>9</a>"
- Retval=Retval & " ... "
- End If
- If EndPage>PageCount Then EndPage=PageCount
- For J = StartPage to EndPage
- If J = Page Then
- Retval = Retval & " <font color=#999999>" & J & "</font>"
- Else
- Retval = Retval & " <a href='" & LinkFile & "Page=" & J & "'>" & J & "</a>"
- End If
- Next
- If EndPage < PageCount Then Retval= Retval & " ... <a href='" & LinkFile & "Page=" & PageCount & "' style='font-family:webdings' title='末页'>:</a>"
- Retval=Retval & "</td>"
- Retval=Retval & "</tr>"
- Retval=Retval & "</table>"
- ShowPage=Retval
- End Function
- %>
如果你在使用过程中遇到什么问题,欢迎把您的反馈信息告诉我!
评论: 0 | 引用: 0 | 查看次数: 721 |
返回顶部