sub_turnpage.asp

来自「CityCN V2.1 是自主开发的基于ASP+Access的新型资讯信息系统。」· ASP 代码 · 共 77 行

ASP
77
字号
<%
'+++++++++++++++++++++++++++++++++++++
'◆模块名称: 公共翻页模块
'◆文 件 名: TurnPage.asp
'◆传入参数: Rs_tmp (记录集), PageSize (每页显示的记录条数)
'◆输 出: 记录集翻页显示功能

'调用方法:
'  1、在程序开始或要使用翻页的地方包含翻页模块文件;
'  2、定义变量:RowCount,每页显示的记录条数
'  3、调用翻页过程:Call TurnPage(记录集,RowCount)
'  4、在Do While 循环输出记录集的条件中加上" RowCount > 0 " 条件
'  5、在循环结束 "Loop前" 加上: RowCount = RowCount - 1
'+++++++++++++++++++++++++++++++++++++

Sub TurnPage(ByRef Rs_tmp,PageSize) 'Rs_tmp 记录集 ; PageSize 每页显示的记录条数;
Dim TotalPage '总页数
Dim PageNo '当前显示的是第几页
Dim RecordCount '总记录条数
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)
%>
<div id="cutpage"><table border='0' width='100%' height='25'>
<tr>
<td align=right style='font-size: 10pt;'><%=PageNo%>/<%=TotalPage%>页</td>
<td align="right" style='font-size: 11pt; font-family: Webdings'>
<%If RecordCount = 0 or TotalPage = 1 Then
Response.Write "9 7 8 :"
Else%>
<a href="<%=fileName%>?ct=<%=mycity%>&lb=<%=myleibie%>&PageNo=1">9</a>
<%If PageNo - 1 = 0 Then
Response.Write "7 "
Else%>
<a href="<%=fileName%>?ct=<%=mycity%>&lb=<%=myleibie%>&PageNo=<%=PageNo-1%>">7</a>
<%End If

If PageNo+1 > TotalPage Then
Response.Write "8 "
Else%>
<a href="<%=fileName%>?ct=<%=mycity%>&lb=<%=myleibie%>&PageNo=<%=PageNo+1%>">8</a>
<%End If%>

<a href="<%=fileName%>?ct=<%=mycity%>&lb=<%=myleibie%>&PageNo=<%=TotalPage%>">:</a>
<%End If%></td>

<td align="right">
<select name="sel_page" onchange="javascript:location=this.options[this.selectedIndex].value;">
  <%
   dim ii
   for ii = 1 to TotalPage
   %>
   <option value="<%=fileName%>?ct=<%=mycity%>&lb=<%=myleibie%>&PageNo=<%=ii%>" <%if cstr(ii)=cstr(pageno) then%>selected<%end if%>>第<%=ii%>页</option>
   <%
   next
   %>
</select>
</td>
</tr> 
</table>
</div>
<%End Sub%>

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?