ASP 分页函数
2011-01-06 13:28
197 查看
<%@LANGUAGE="VBSCRIPT" CODEPAGE="65001"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>分页示例</title>
</head>
<%
' Pagination Function
' Created by Bendy on 2010-12-11
SUB Pager(intTotalRecord, intPageSize, intCurrentPage, strUrl)
if (not IsNumeric(intTotalRecord) or not IsNumeric(intPageSize) or not IsNumeric(intCurrentPage)) then
exit sub
end if
intTotalRecord = Clng(intTotalRecord)
intPageSize = Clng(intPageSize)
intCurrentPage = Clng(intCurrentPage)
' Init variable
dim intPageCount, intShowPageCount, intBeginPage, intEndPage
intShowPageCount = 10
intPageCount = intTotalRecord \ intPageSize
if (intTotalRecord mod intPageSize > 0) then
intPageCount = intPageCount + 1
end if
if (intPageCount <= 1) then
exit sub
end if
if (intCurrentPage > intPageCount) then
intCurrentPage = intPageCount
end if
if (intCurrentPage < 0) then
intCurrentPage = 1
end if
if (intPageCount < intShowPageCount) then
intShowPageCount = intPageCount
end if
intBeginPage = intCurrentPage - intShowPageCount \ 2 + 1 ' ((intCurrentPage \ intShowPageCount) * intShowPageCount + 1)
intEndPage = intCurrentPage + intShowPageCount \ 2 '((intCurrentPage \ intShowPageCount + 1) * intShowPageCount)
if (intBeginPage < 1) then
intBeginPage = 1
intEndPage = intShowPageCount
end if
if (intEndPage > intPageCount) then
intBeginPage = intPageCount - intShowPageCount + 1
intEndPage = intPageCount
end if
' Get current URL
if (strUrl = "") then
strUrl = request.ServerVariables("SCRIPT_NAME")
for each strQueryKey in request.QueryString
if (strQueryKey <> "page") then
if (InStr(strUrl, "?") <= 0) then
strUrl = strUrl & "?" & strQueryKey & "=" & request.QueryString(strQueryKey)
else
strUrl = strUrl & "&" & strQueryKey & "=" & request.QueryString(strQueryKey)
end if
end if
next
else
if (InStr(strUrl, "?") <= 0) then
strUrl = strUrl & "?1=1"
end if
end if
' Begin render the control
response.Write("<table class='tblPager'><tr>")
if (intBeginPage > 1) then
response.Write("<td><a href='" & strUrl & "&page=1'>|<</a></td>")
else
response.Write("<td class='disable'>|<</td>")
end if
if (intCurrentPage > 1) then
response.Write("<td><a href='" & strUrl & "&page=" & CStr(intCurrentPage-1) & "'><<</a></td>")
else
response.Write("<td class='disable'><<</td>")
end if
for i = intBeginPage to intEndPage
if (i = intCurrentPage) then
response.Write("<td class='currentPage'>" & CStr(i) & "</td>")
else
response.Write("<td><a href='" & strUrl & "&page=" & CStr(i) & "'>" & CStr(i) & "</a></td>")
end if
next
if (intCurrentPage < intPageCount) then
response.Write("<td><a href='" & strUrl & "&page=" & CStr(intCurrentPage+1) & "'>>></a></td>")
else
response.Write("<td class='disable'>>></td>")
end if
if (intEndPage < intPageCount) then
response.Write("<td><a href='" & strUrl & "&page=" & intPageCount & "'>>|</a></td>")
else
response.Write("<td class='disable'>>|</td>")
end if
response.Write("</tr></table>")
END SUB
%>
<style type="text/css">
.tblPager {}
.tblPager td { width:50px; border:solid 1px #efefef; text-align:center;}
.tblPager .disable { color:#999999;}
.tblPager .currentPage { font-weight:bold;}
</style>
<body>
<% dim currentPage
currentPage = request.QueryString("page")
%>
<% call Pager(320, 10, currentPage, "pager.asp?b=3&c=3") %>
<br />
<% call Pager(0, 10, currentPage, "") %>
<br />
<% call Pager(8, 10, currentPage, "") %>
<br />
<% call Pager(320, 10, currentPage, "") %>
<br />
</body>
</html>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>分页示例</title>
</head>
<%
' Pagination Function
' Created by Bendy on 2010-12-11
SUB Pager(intTotalRecord, intPageSize, intCurrentPage, strUrl)
if (not IsNumeric(intTotalRecord) or not IsNumeric(intPageSize) or not IsNumeric(intCurrentPage)) then
exit sub
end if
intTotalRecord = Clng(intTotalRecord)
intPageSize = Clng(intPageSize)
intCurrentPage = Clng(intCurrentPage)
' Init variable
dim intPageCount, intShowPageCount, intBeginPage, intEndPage
intShowPageCount = 10
intPageCount = intTotalRecord \ intPageSize
if (intTotalRecord mod intPageSize > 0) then
intPageCount = intPageCount + 1
end if
if (intPageCount <= 1) then
exit sub
end if
if (intCurrentPage > intPageCount) then
intCurrentPage = intPageCount
end if
if (intCurrentPage < 0) then
intCurrentPage = 1
end if
if (intPageCount < intShowPageCount) then
intShowPageCount = intPageCount
end if
intBeginPage = intCurrentPage - intShowPageCount \ 2 + 1 ' ((intCurrentPage \ intShowPageCount) * intShowPageCount + 1)
intEndPage = intCurrentPage + intShowPageCount \ 2 '((intCurrentPage \ intShowPageCount + 1) * intShowPageCount)
if (intBeginPage < 1) then
intBeginPage = 1
intEndPage = intShowPageCount
end if
if (intEndPage > intPageCount) then
intBeginPage = intPageCount - intShowPageCount + 1
intEndPage = intPageCount
end if
' Get current URL
if (strUrl = "") then
strUrl = request.ServerVariables("SCRIPT_NAME")
for each strQueryKey in request.QueryString
if (strQueryKey <> "page") then
if (InStr(strUrl, "?") <= 0) then
strUrl = strUrl & "?" & strQueryKey & "=" & request.QueryString(strQueryKey)
else
strUrl = strUrl & "&" & strQueryKey & "=" & request.QueryString(strQueryKey)
end if
end if
next
else
if (InStr(strUrl, "?") <= 0) then
strUrl = strUrl & "?1=1"
end if
end if
' Begin render the control
response.Write("<table class='tblPager'><tr>")
if (intBeginPage > 1) then
response.Write("<td><a href='" & strUrl & "&page=1'>|<</a></td>")
else
response.Write("<td class='disable'>|<</td>")
end if
if (intCurrentPage > 1) then
response.Write("<td><a href='" & strUrl & "&page=" & CStr(intCurrentPage-1) & "'><<</a></td>")
else
response.Write("<td class='disable'><<</td>")
end if
for i = intBeginPage to intEndPage
if (i = intCurrentPage) then
response.Write("<td class='currentPage'>" & CStr(i) & "</td>")
else
response.Write("<td><a href='" & strUrl & "&page=" & CStr(i) & "'>" & CStr(i) & "</a></td>")
end if
next
if (intCurrentPage < intPageCount) then
response.Write("<td><a href='" & strUrl & "&page=" & CStr(intCurrentPage+1) & "'>>></a></td>")
else
response.Write("<td class='disable'>>></td>")
end if
if (intEndPage < intPageCount) then
response.Write("<td><a href='" & strUrl & "&page=" & intPageCount & "'>>|</a></td>")
else
response.Write("<td class='disable'>>|</td>")
end if
response.Write("</tr></table>")
END SUB
%>
<style type="text/css">
.tblPager {}
.tblPager td { width:50px; border:solid 1px #efefef; text-align:center;}
.tblPager .disable { color:#999999;}
.tblPager .currentPage { font-weight:bold;}
</style>
<body>
<% dim currentPage
currentPage = request.QueryString("page")
%>
<% call Pager(320, 10, currentPage, "pager.asp?b=3&c=3") %>
<br />
<% call Pager(0, 10, currentPage, "") %>
<br />
<% call Pager(8, 10, currentPage, "") %>
<br />
<% call Pager(320, 10, currentPage, "") %>
<br />
</body>
</html>
相关文章推荐
- 2006-4-22 ASP VBScript 分页函数 by Stabx, 2006-04-22
- 一个ASP.NET长文章分页显示函数
- GetPaing 函数之asp采集函数中用到的获取分页的代码
- ASP实现长文章自动分页的函数代码
- js实现ASP分页函数 HTML分页函数
- Asp.net 高性能数据分页函数,调用示例
- asp数字分页函数 实际使用例子。
- ASP长文章分页的两个方法,函数
- asp 分页 函数 及调用 例子
- ASP VBScript 分页函数 by Stabx, 最终版 2006-5-22
- 一个实用的ASP分页函数,解决你重复写分页代码的烦恼
- asp文章内容分页的函数
- ASP.NET 数据分页第一篇—探讨分页原理及 SQL Server 2005 的 ROW_NUMBER 函数
- ASP通用分页样式函数代码
- 一个ASP.NET长文章分页显示函数
- 一个ASP.NET长文章分页显示函数
- ASP实现长文章自动分页的函数代码
- ASP 通用文章分页函数(非记录集分页), 返回多个结果, 字典实现 By shawl.qiu
- ASP实现长文章自动分页的函数代码
- ASP.NET C# 后台输出的带页码的分页函数(不用控件)