公共翻页模块

2006-04-02 程序代码 1127 阅读 0 评论

设计方法:
1、调用该模块时,只需要传递记录集和每页显示的记录的条数;
2、可以点击链接进行翻页,也可以直接输入页码,回车后翻页;
3、不要考虑文件名,程序的每次翻页都能在当前页面。

想清楚了上面3个问题,我们的公共翻页模块就可以动手了。

"" then
MyVar =Request.QueryString ("PageNo")
MyCheck = IsNumeric(MyVar)
 if MyCheck=True then
 PageNo = Cint(Request.QueryString ("PageNo"))
 else
 PageNo = 1
 end if
end if

'直接输入页数跳转;
If Request.Form("PageNo")"" Then
MyVar1 =Request.Form("PageNo")
MyCheck1 = IsNumeric(MyVar1)
 if MyCheck1=True then
 PageNo = Cint(Request.Form("PageNo"))
 else
 PageNo = 1
 end if
end if
'如果没有选择第几页,则默认显示第一页;
If PageNo = "" then PageNo = 1
If RecordCount  0 then
Rs_tmp.AbsolutePage = PageNo
End If

'获取当前文件名,使得每次翻页都在当前页面进行;
Dim fileName,postion,fileString
fileName = Request.ServerVariables("script_name")
fileString = Request.ServerVariables("QUERY_STRING")
postion = InstrRev(fileName,"/")+1
'取得当前的文件名称,使翻页的链接指向当前文件;
fileName = Mid(fileName,postion)
%>

method=get>
页 /

当前 第 页 每页
Response.Write "首页 | 前页 | 后页 | 末页"
Else%> 首页 | Response.Write "前页 |"
Else%> 前页 |
If PageNo+1 > TotalPage Then
Response.Write "后页 |"
Else%> 后页 |
末页
转到第





1 Then%>

大家可以把翻页的链接做成图片按钮,这样的话也面就更加美观了。

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

使用范例:

1.首先请将以上代码框内代码转存为pagein.asp

2.我们新建一个ASP页面,内容如下


 '引入公共翻页模块

标签内容)
Dim Repeat2__numRows
Dim Repeat2__index

Repeat2__numRows = 20
Repeat2__index = 0
rsnews_numRows = rsnews_numRows + Repeat2__numRows
%>


dim RowCount
RowCount = 20
call TurnPage(rsnews,RowCount)
%>
0) AND (NOT rsnews.EOF)) %>

RowCount = 20
call TurnPage(rsnews,RowCount)
%>

本文链接:https://blog.clang.cn/292.html

版权声明:转载请注明出处。

评论 (0)

评论已关闭