创建一个ASP通用分页类

2019-04-02 22:47:28王冬梅

  '========================
  If request("page")="" Then
  int_curpage=1
  ElseIf not(IsNumeric(request("page"))) Then
  int_curpage=1
  ElseIf CInt(Trim(request("page")))<1 Then
  int_curpage=1
  Else
  Int_curpage=CInt(Trim(request("page")))
  End If  
End Sub到这里这个类分的功能基本已经实现了,只要在调用这个类的页面的URL后面加上page=n,它就会显示第n页的内容了,所以接下去要做的就是创建一个数据导航条了,我把它设计为类似以面的形式

9 3[1] [2] [3] [4] [5] [6] [7] [8] 4 :页次:1/8页 共51条记录 7条/每页

在页面里通过调用ShowPage()的方法显示出来,ShowPage可以在GetRS以后的任意位置调用,也可以调用多次
Public Sub ShowPage()
Dim str_tmp
int_totalRecord=XD_RS.RecordCount
If int_totalRecord<=0 Then
  str_error=str_error & "总记录数为零,请输入数据"
  Call ShowError()
End If
If int_totalRecord="" Then
  int_TotalPage=1
Else
  If int_totalRecord mod PageSize =0 Then