支持多风格变换的ASP分页类

2016-02-19 19:28 3 1 收藏

下面请跟着图老师小编一起来了解下支持多风格变换的ASP分页类,精心挑选的内容希望大家喜欢,不要忘记点个赞哦!

【 tulaoshi.com - Web开发 】

  这个分页使用的是0游标,也就是Rs.Open Sql,Conn,0,1。但是感觉也快不了多少,10
  万条数据的分页时间300多豪秒之间
  %
  Class Page
  Private CurrPage
  Private PageN
  Private UrlStr
  Private TempStr
  Private ErrInfo
  Private IsErr
  Private TotalRecord
  Private TotalPage
  Public  PageRs

(本文来源于图老师网站,更多请访问https://www.tulaoshi.com/webkaifa/)

  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
  '------------------------------------------------------------

(本文来源于图老师网站,更多请访问https://www.tulaoshi.com/webkaifa/)

  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.Number0 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 CurrPage1 Then CurrPage=1
        If CurrPageTotalPage 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

来源:https://www.tulaoshi.com/n/20160219/1621110.html

延伸阅读
标签: Web开发
具体调用参见打包文件中的index.html文件,简单来说就是在欲调用页面的主体布局结束之前加上  程序代码 div id="topbar"/div 下面这些可以放到/body之前。  程序代码 span id="span_float_qq"script src="qq.js" type="text/javascript"/script/span script type="text/javascript"$("topbar").innerHTML=$("span_float_qq").inne...
标签: Web开发
html head titleAJAX静态分页演示:http://www.jb51.net/title meta http-equiv="content-type" content="text/html;charset=gb2312" style type="text/css" !-- body                { text-align:center;font:14px Verdana,sans-serif; } a:link,a...
% 'asp+mysql分页,由axislover原创于2007年12月11日,是个雪花飘飘的日子 Dim strSql,Rs Dim intRecordNum,intCurrentPage,intRowcount intRowcount = 0 Dim intPageCount:intPageCount = 15  '每页20条记录 GetConn_Open '获得总记录 Set Rs = Conn.Execute("SELECT COUNT(*) As intcounts FROM datainfo where sort=1 and ...
标签: Web开发
代码如下: !-- //ASP分页函数 function ShowListPage(page,Pcount,TopicNum,maxperpage,strLink,ListName){     var alertcolor = '#FF0000';     maxperpage=Math.floor(maxperpage);     TopicNum=Math.floor(TopicNum);     p...
标签: ASP
  大概在九九年做游戏网站的时候,就对文章的发布感到麻烦,不过那会儿玩ASP不精。只是将就用着。在遇到长文件 10000 字时网页就是一大片长了。 去年,做一个通用的文章与新闻管理系统时,曾写了一段代码,用来分离。现在贴出来。 要说明的是: 我的文章 录入界面是基于WEB的HEMLEDITOR,就像这里的ABC代码差不多。所以实际提交的是HT...

经验教程

976

收藏

52
微博分享 QQ分享 QQ空间 手机页面 收藏网站 回到头部