加入收藏 | 设为首页 | 会员中心 | 我要投稿 应用网_丽江站长网 (http://www.0888zz.com/)- 科技、建站、数据工具、云上网络、机器学习!
当前位置: 首页 > 站长学院 > Asp教程 > 正文

另外一个分页类:支持多风格变换的ASP分页类 - ASP教程

发布时间:2016-05-19 09:46:38 所属栏目:Asp教程 来源:网络整理
导读:% '****************************** '名称:分页类 '日期:2005/12/3 '作者:西楼冷月 '网址:www.xilou.net | www.chinaCMS.org '描述:无 '版权:转载请注名
<%
'******************************
'名称:分页类
'日期:2005/12/3
'作者:西楼冷月
'网址:www.xilou.net | www.chinaCMS.org
'描述:无
'版权:转载请注名出处,作者
'******************************
Class Page
Private CurrPage
Private PageN
Private UrlStr
Private TempStr
Private ErrInfo
Private IsErr
Private TotalRecord
Private TotalPage
Public PageRs

Private TempA(11)
Private TempB(8)
'------------------------------------------------------------
Private Sub Class_Initialize()
CurrPage=1'//默认显示当前页为第一页
PageN=10'//默认每页显示10条数据
UrlStr="#"
TempStr=""
ErrInfo="ErrInfo:"
IsErr=False
End Sub
Private Sub Class_Terminate()
If IsObject(PageRs) Then
PageRs.Close
Set PageRs=Nothing
End If
Erase TempA
Erase TempB
End Sub
'----------------------------------------------------------
'//获取当前页码
Public Property Let CurrentPage(Val)
CurrPage=Val
End Property
Public Property Get CurrentPage()
CurrentPage=CurrPage
End Property
'//获取每页显示条数
Public Property Let PageNum(Val)
PageN=Val
End Property
Public Property Get PageNum()
PageNum=PageN
End Property
'//获取URL
Public Property Let Url(Val)
UrlStr=Val
End Property
Public Property Get Url()
Url=UrlStr
End Property
'//获取模板
Public Property Let Temp(Val)
TempStr=Val
End Property
Public Property Get Temp()
Temp=TempStr
End Property
'------------------------------------------------------------

Public Sub Exec(Sql,ConnObj)
On Error Resume Next
Set PageRs=Server.CreateObject("ADODB.RecordSet")
PageRs.CursorLocation = 3 '使用客户端游标,可以使效率提高
PageRs.PageSize = PageN '定义分页记录集每页显示记录数
PageRs.Open Sql,ConnObj,0,1
If Err.Number<>0 Then
Err.Clear
PageRs.Close
Set PageRs=Nothing
ErrInfo=ErrInfo&"建立或打开记录集错误..."
IsErr=True
Response.Write ErrInfo
Response.End
End If
TotalRecord=PageRs.RecordCount'//如果为0呢?
If TotalRecord>=1 Then
'----------------------------------------------------------------------------开始
'//计算总页数,Ps,为什么不用PageRs.PageCount呢?
'If TotalRecord Mod PageN=0 Then
'TotalPage=PageRs.RecordCountPageN
'Else
'TotalPage=PageRs.RecordCountPageN
'TotalPage=Abs(Int(TotalPage))
'End If
TotalPage=PageRs.PageCount
'//处理当前接收页码,默认的为1,所以不是数字类型的都会为1
If IsNumeric(CurrPage) Then
CurrPage=CLNg(CurrPage)
If CurrPage<1 Then CurrPage=1
If CurrPage>TotalPage Then CurrPage=TotalPage
Else
'//Dim M:M="":IsNumeric(M)=True
CurrPage=1
End If
'---------------------------------------------------------------------------结束
Else
TotalPage=0
CurrPage=1
End If
'//
PageRs.AbsolutePage = CurrPage 'absolutepage:设置指针指向某页开头
PageRs.PageSize=PageN
End Sub
Private Sub Init()
'Private TempA(10)
TempA(1)="{N1}" '//首页
TempA(2)="{N2}"'//上一页
TempA(3)="{N3}"'//下一页
TempA(4)="{N4}"'//尾页
TempA(5)="{N5}"'//当前页码
TempA(6)="{N6}"'//页码总数
TempA(7)="{N7}"'//每页条数
TempA(8)="{N8}"'//文章总数
TempA(9)="{L}"'//循环标签开始
TempA(10)="{N}"'//循环内单标签:页码
TempA(11)="{L

(编辑:应用网_丽江站长网)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读