<%'---------------------------------------------------------
'本程序适合access数据库asp程序分页,其它类型数据库可参考。
'本程序特点是模块化,可在多个分页文件中调用,简化每个分页文件
'效果:
740)this.width=740" border=undefined>
'有明确注释,直接套用,需修改的部位不多。
'可自由修改使用本程序,但敬请保留本版权信息
'博大多媒体工作室 http://www.ip126.com
'------------------------------------------------------------
%>
<%'=============公共翻页模块开始=================================
'这部分存为单独文件,名为Page.asp,在使用分页的文件中用<!--#include file="Page.asp" -->形式调用
Sub TurnPage(ByRef Rs_tmp,PageSize,Incl) 'Rs_tmp 记录集 ; PageSize 每页显示的记录条数;Incl 其它参数
Dim TotalPage '总页数
Dim PageNo '当前显示的是第几页
Dim RecordCount '总记录条数
If Incl=false then Incl=""
Rs_tmp.PageSize = PageSize
RecordCount = Rs_tmp.RecordCount
TotalPage = INT(RecordCount / PageSize * -1)*-1
PageNo = Request.QueryString ("PageNo")
'直接输入页数跳转;
If Request.Form("PageNo")<>"" Then PageNo = Request.Form("PageNo")
'如果没有选择第几页,则默认显示第一页;
If PageNo = "" then PageNo = 1
If RecordCount <> 0 then
Rs_tmp.AbsolutePage = PageNo
End If
'获取当前文件名,使得每次翻页都在当前页面进行;
Dim fileName,postion
fileName = Request.ServerVariables("script_name")
postion = InstrRev(fileName,"/")+1
'取得当前的文件名称,使翻页的链接指向当前文件;
fileName = Mid(fileName,postion)
%>
<form name=pageform method="post" action="<%=fileName%>?PageNo=<%=PageNo%><%=Incl%>">共 <font color=#ff3333><strong><%=rs_tmp.recordcount%></strong></font> 条记录|每页 <font color=#ff3333><strong><%=RowCount%></strong></font> 个记录|分 <font color=#ff3333><strong><%=TotalPage%></strong></font> 页|当前第 <strong><font color=#ff3333><%=PageNo%></font></strong> 页
<%If RecordCount = 0 or TotalPage = 1 Then
Response.Write "|<< 首页 < 前页 | 后页 > 末页>|"
Else%>
<a href="<%=fileName%>?PageNo=1<%=Incl%>">|<<
首页</a>
<%If PageNo - 1 = 0 Then
Response.Write "< 前页 |"
Else%>
<a href="<%=fileName%>?PageNo=<%=PageNo-1%><%=Incl%>"><
前页</a> |
<%End If
If PageNo+1 > TotalPage Then
Response.Write "后页 >"
Else%>
<a href="<%=fileName%>?PageNo=<%=PageNo+1%><%=Incl%>">后页
></a>
<%End If%>
<a href="<%=fileName%>?PageNo=<%=TotalPage%><%=Incl%>">末页>>|</a>
<%End If%>
| 转到第
<%If TotalPage = 1 Then%> <input type=text name=PageNo size=3 readonly disabled style="background:#d3d3d3">
<%Else%> <input type=text name=PageNo size=3 value="" title=请输入页号,然后回车>
<%End If%>
页
<input type="submit" class=button_index name="Submit" value="提交">
</form>
<%End Sub
'=============公共翻页模块结束=================================%>
<%'===========公共翻页模块开始,放在数据库打开后
RowCount =15 '每页显示的记录条数
incl="&kindid1="&kindid1&"&kindid2="&kindid2 '翻页时的其它参数,如果没有这些参数填incl=false
Call TurnPage(Rs,RowCount,Incl) '调用分页
'===========公共翻页模块结束%>
<%'===========循环体开始
do while not rs.eof and rowcount>0%>
<!---此处为内容循环输出---->
<%
rowcount=rowcount-1 '-----分页参数
rs.movenext
loop
rs.close:conn.close '释放资源
set rs=nothing:set conn=nothing
'===========循环体结束%>
浙公网安备 33010602011771号