下面,图老师小编带您去了解一下DreamweaverASP实现分页技术,生活就是不断的发现新事物,get新技能~
【 tulaoshi.com - Web开发 】
今天心情有点激动,想把"关于用DW+ASP实现分页技术的参考"分享给用DW+ASP做网页的朋友们.去掉只有"第一页,前一页,下一页,最后一页"的小痛苦
(本文来源于图老师网站,更多请访问http://www.tulaoshi.com/webkaifa/)此效果最后的显示是:第N页[共*页] 1 2 3 4 5 6 7 8 9 10 。
用DW+ASP做网页时,在绑定记录集后,代码页里马上出现以下代码:
%
Dim Recordset1
Dim Recordset1_numRows
Set Recordset1 = Server.CreateObject("ADODB.Recordset")
Recordset1.ActiveConnection = MM_数据库名_STRING
Recordset1.Source = "SELECT * FROM 表名"
Recordset1.CursorType = 0
Recordset1.CursorLocation = 2
Recordset1.LockType = 1
Recordset1.Open()
Recordset1_numRows = 0
%
现在我们要来对代码做点修改,请在上面代码中修改为如下的代码:
%
Dim I
Dim RPP
Dim PageNo
I=1
RPP=50
PageNo=CInt(Request("PageNo"))
’上面即是新插入的,
Dim Recordset1
Dim Recordset1_numRows
Set Recordset1 = Server.CreateObject("ADODB.Recordset")
Recordset1.ActiveConnection = MM_数据库名_STRING
Recordset1.Source = "SELECT * FROM 数据库名"
Recordset1.CursorType = 1 ’将上面代码的0改为1.
Recordset1.CursorLocation = 2
Recordset1.LockType = 1
Recordset1.Open()
Recordset1_numRows = 0 ’再在此行的下一行开始加入如下代码:
Recordset1.PageSize=RPP
If PageNo=0 Then PageNo=1
If PageNoRecordset1.PageCount Then PageNo=Recordset1.PageCount
Recordset1.AbsolutePage=PageNo
Sub ShowPageInfo(tPageCount,cPageNo)
Response.Write "第"&cPageNo&"页[共"&tPageCount&"页]"
End Sub
Sub ShowPageNavi(tPageCount,cPageNo)
If cPageNo1 Then cPageNo=1
If tPageCount1 Then tPageCount=1
If cPageNotPageCount Then cPageNo=tPageCount
Dim NaviLength
NaviLength=10 ’NaviLength:显示的数字链接个数
Dim I,StartPage,EndPage
StartPage=(cPageNoNaviLength)*NaviLength+1
If (cPageNo Mod NaviLength)=0 Then StartPage=StartPage-NaviLength
EndPage=StartPage+NaviLength-1
If EndPagetPageCount Then EndPage=tPageCount
If StartPage1 Then
Response.Write "a class=""pageNavi"" href=""?PageNo=" & (cPageNo-NaviLength) & """/a "
Else
Response.Write "font color=""#CCCCCC""/font "
End If
For I=StartPage To EndPage
If I=cPageNo Then
Response.Write "b"&I&"/b"
Else
Response.Write "a class=""pageNavi"" href=""?PageNo=" & I & """" & I & "/a"
End If
If ItPageCount Then Response.Write " "
Next
If EndPagetPageCount Then
Response.Write " a class=""pageNavi"" href=""?PageNo=" & (cPageNo+NaviLength) & """/a"
Else
Response.Write " font color=""#CCCCCC""/font "
End If
End Sub
%
来源:http://www.tulaoshi.com/n/20160219/1622212.html
看过《DreamweaverASP实现分页技术》的人还看了以下文章 更多>>