⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 turnpage.asp

📁 网上学生心里调查系统
💻 ASP
字号:
<% 
'+++++++++++++++++++++++++++++++++++++ 
'◆模块名称: 公共翻页模块 
'◆文 件 名: 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)  
%> 
<table border=0 width=100% height="25">  
<tr>  
<td align=left> 总页数:<font color=#ff3333><%=TotalPage%></font>页 
  当前第<font color=#ff3333><%=PageNo%></font>页</td> 
<td align="right">  
<%If RecordCount = 0 or TotalPage = 1 Then  
Response.Write "首页 | 前页 | 后页 | 末页" 
Else%> 
<a href="<%=fileName%>?PageNo=1">首页</a> | 
<%If PageNo - 1 = 0 Then 
Response.Write "前页 |" 
Else%> 
<a href="<%=fileName%>?PageNo=<%=PageNo-1%>">前页</a> |
<%End If 

If PageNo+1 > TotalPage Then 
Response.Write "后页 |" 
Else%> 
<a href="<%=fileName%>?PageNo=<%=PageNo+1%>">后页</a> | 
<%End If%> 

<a href="<%=fileName%>?PageNo=<%=TotalPage%>">末页</a> 
<%End If%></td> 
<td width=95 align="right"> 
<%
'If TotalPage = 1 Then
'Response.Write"转到第<input type=text name=PageNo size=3 readonly disabled style=background:#d3d3d3> "
'Else 
'Response.Write"<input type=text name=PageNo size=3 value='' title=请输入页号,然后回车>页"
'End If%> 

<select name="sel_page" onchange="javascript:location=this.options[this.selectedIndex].value;">
  <%
   dim ii
   for ii = 1 to TotalPage
   %>
   <option value="<%=fileName%>?PageNo=<%=ii%>" <%if cstr(ii)=cstr(pageno) then%>selected<%end if%>>第<%=ii%>页</option>
   <%
   next
   %>
</select>

</td> 
</tr> 
</table> 

<%End Sub%>

⌨️ 快捷键说明

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