asp 文章分页类

asp 文章分页类

<%

Class Cls_Page

 '**************************************************
 '函数名:ShowPage
 '作  用:显示分页
 '参  数:如下
 'strFileName : ?后面的文件,如xxx.asp?page=
 'xTotalNum  : 总数
 'xPageCount     : 总页数
    'xMaxPerPage : 每页显示数量
 'xCurrentPage : 当前页数
 'xPageName  : 当前页面名
 'xUnitName  : 分类单位名称,如"篇,条,幅"
 'xShowStyle  : 显示分页的样式
 '返回值:分页
 '**************************************************
 Public Function ShowPage

(strFileName,xTotalNum,xPageCount,xMaxPerPage,xCurrentPage,xPageName,xUnitNa

me,xShowStyle)
  strUrl = ClsMain.JoinChar(strFileName)
  Dim i,PageStr
  If xTotalNum > 0 Then
   If xPageCount >= 1 Then
    Select Case xShowStyle
     Case "1" '分页样式1:列出所有

页码的页号,页码较少时可以使用
      PageStr = PageStr & "<div

id=""ShowPage"">"
      PageStr = PageStr & "<a

class=""TotalPage"">全部"&xPageName&":<b>" & xTotalNum &"</b>" & xUnitName

& "</a>"
      PageStr = PageStr &

"&nbsp;<a class=""PageInfo"">页次:<b>" & xCurrentPage & "/" & xPageCount &

"</b></a>"
      For i=1 To xPageCount
       If i = xCurrentPage

Then
        PageStr =

PageStr & "&nbsp;[<a class=""CurrentPage""><font color='red'>" & i &

"</font></a>]"
       Else
        PageStr =

PageStr & "&nbsp;[<a href=""" & strUrl & "Page=" & i & """

class=""GoToPage"">" & i & "</a>]"
       End If
      Next
      PageStr = PageStr &

"</div>"&vbcrlf
     Case "2" '分页样式2:显示首页

、上一页、下一页、末页,均为符号和转到页的输入框
      PageStr = PageStr & "<div

id=""ShowPage"">"
      PageStr = PageStr & "<a

class=""TotalPage"">全部"&xPageName&":<b>" & xTotalNum &"</b>" & xUnitName

& "</a>"
      PageStr = PageStr &

"&nbsp;<a class=""PageInfo"">页次:<b>" & xCurrentPage & "/" & xPageCount &

"</b></a>"
      If xCurrentPage > 1 Then
       PageStr = PageStr &

"&nbsp;<a href=""" & strUrl & "Page=1"" title=""首页""

class=""FirstPage"">|&lsaquo;</a>"
       PageStr = PageStr &

"&nbsp;<a href=""" & strUrl & "Page=" & xCurrentPage - 1 & """ title=""上一

页"" class=""PrevPage"">&laquo;</a>"
      Else
       PageStr = PageStr &

"&nbsp;<a class=""FirstPage"">|&lsaquo;</a>"
       PageStr = PageStr &

"&nbsp;<a class=""PrevPage"">&laquo;</a>"
      End If
      If xCurrentPage < xPageCount

Then
       PageStr = PageStr &

"&nbsp;<a href=""" & strUrl & "Page=" & xCurrentPage + 1 & """ title=""下一

页"" class=""NextPage"">&raquo;</a>"
       PageStr = PageStr &

"&nbsp;<a href=""" & strUrl & "Page=" & xPageCount & """ title=""末页""

class=""LastPage"">&rsaquo;|</a>"&vbcrlf
      Else
       PageStr = PageStr &

"&nbsp;<a class=""NextPage"">&raquo;</a>"
       PageStr = PageStr &

"&nbsp;<a class=""LastPage"">&rsaquo;|</a>"&vbcrlf
      End If
      PageStr = PageStr & " 

<input id=""page"" type=""text"" value=""" & xCurrentPage & """

maxlength=""4"" title=""定页"" size='4' onmouseover=""javascript:this.focus

();this.select()"" onKeyDown=""javascript: if(window.event.keyCode == 13)

window.location.href='" & strUrl & "page='+this.value"">"&vbcrlf
      PageStr = PageStr & " 

<input type=""button"" value=""Go"" onclick=""javascript:if

(document.getElementById('page')) window.location.href='" & strUrl &

"Page='+document.getElementById('page').value"">"&vbcrlf
      PageStr = PageStr &

"</div>"&vbcrlf
     Case "3" '分页样式3:显示首页

、上十页、下十页、尾页以及中间一段页码
      PageStr = PageStr & "<div

id=""ShowPage"">"
      PageStr = PageStr & "<a

class=""TotalPage"">全部"&xPageName&":<b>" & xTotalNum &"</b>" & xUnitName

& "</a>"
      PageStr = PageStr &

"&nbsp;<a class=""PageInfo"">页次:<b>" & xCurrentPage & "/" & xPageCount &

"</b></a>"
      p = (xCurrentPage - 1) 10
      If xCurrentPage = 1 Then
       PageStr = PageStr &

"&nbsp;<a class=""FirstPage"">|&lsaquo;</a>"
      Else
       PageStr = PageStr &

"&nbsp;<a href=""" & strUrl & "Page=1"" title=""首页""

class=""FirstPage"">|&lsaquo;</a>"
      End If
      If p * 10 > 0 Then
       PageStr = PageStr &

"&nbsp;<a href=""" & strUrl & "Page=" & xCurrentPage - 10 & """ title=""上十

页"" class=""PrevPage"">&laquo;</a>"
      End If
      For i=(p * 10 + 1) To (p *

10 + 10)
       If i = xCurrentPage

Then
        PageStr =

PageStr & "&nbsp;[<font color='red'><a class=""CurrentPage"">" & i &

"</a></font>]"
       Else
        PageStr =

PageStr & "&nbsp;<a href=""" & strUrl & "Page=" & i & """ title=""转到第" &

i & "页"" class=""GoToPage"">" & i & "</a>"
       End If
       If i = xPageCount

Then Exit For
      Next
      If i < xPageCount Then

PageStr = PageStr & "&nbsp;<a href=""" & strUrl & "Page=" & i & """ title=""

下十页"" class=""NextPage"">&raquo;</a>"
      If xCurrentPage = xPageCount

Then
       PageStr = PageStr &

"&nbsp;<a class=""LastPage"">&rsaquo;|</a>"
      Else
       PageStr = PageStr &

"&nbsp;<a href=""" & strUrl & "Page=" & xPageCount & """ title=""末页""

class=""LastPage"">&rsaquo;|</a>"
      End If
      PageStr = PageStr &

"</div>"&vbcrlf
     Case "4" '分页样式4:显示首页

和尾页的页码、中间显示一部分页码
      PageStr = PageStr & "<div

id=""ShowPage"">"
      PageStr = PageStr & "<a

class=""TotalPage"">全部"&xPageName&":<b>" & xTotalNum &"</b>" & xUnitName

& "</a>"
      PageStr = PageStr &

"&nbsp;<a class=""PageInfo"">页次:<b>" & xCurrentPage & "/" & xPageCount &

"</b></a>"
      If xCurrentPage > 4 Then

PageStr = PageStr & "&nbsp;[<a href=""" & strUrl & "Page=1""

class=""FirstPage"">1</a>]&nbsp;...&nbsp;"
      If xCurrentPage < PageCount

- 3 Then PageTo = xCurrentPage + 3 Else PageTo = xPageCount
      For i=xCurrentPage - 3 To

PageTo
       If i >= 1 Then
        If i =

xCurrentPage Then
         

PageStr = PageStr & " &nbsp;[<font color='red'><a class=""CurrentPage"">" &

i & "</a></font>]"
        Else
         

PageStr = PageStr & "&nbsp;[<a href=""" & strUrl & "page=" & i & """

class=""GoToPage"">" & i & "</a>]"
        End If
       End If
      Next
      If xCurrentPage < xPageCount

- 3 Then PageStr = PageStr & "&nbsp;...&nbsp;<a href=""" & strUrl & "Page="

& xPageCount & """ class=""LastPage"">" & xPageCount & "</a>"
      PageStr = PageStr &

"</div>"&vbcrlf
     Case "5" '分页样式5:显示首页

、上一页、下一页、末页,均为汉字和转到页的选择列表
      PageStr = PageStr & "<div

id=""ShowPage"">"
      PageStr = PageStr & "<a

class=""TotalPage"">全部"&xPageName&":<b>" & xTotalNum &"</b>" & xUnitName

& "</a>"
      PageStr = PageStr &

"&nbsp;<a class=""PageInfo"">页次:<b>" & xCurrentPage & "/" & xPageCount &

"</b></a>"
      If xCurrentPage > 1 Then
       PageStr = PageStr &

"&nbsp;<a href=""" & strUrl & "MaxPerPage=" & xMaxPerPage & "&Page=1""

title=""首页"" class=""FirstPage"">首页</a>"
       PageStr = PageStr &

"&nbsp;<a href=""" & strUrl & "MaxPerPage=" & xMaxPerPage & "&Page=" &

xCurrentPage - 1 & """ title=""上一页"" class=""FirstPage"">上一页</a>"
      Else
       PageStr = PageStr &

"&nbsp;<font color='#999999'><a class=""FirstPage"">首页</a></font>"
       PageStr = PageStr &

"&nbsp;<font color='#999999'><a class=""PrevPage"">上一页</a></font>"
      End If
      If xCurrentPage < xPageCount

Then
       PageStr = PageStr &

"&nbsp;<a href=""" & strUrl & "MaxPerPage=" & xMaxPerPage & "&Page=" &

xCurrentPage + 1 & """ title=""下一页"" class=""NextPage"">下一页</a>"
       PageStr = PageStr &

"&nbsp;<a href=""" & strUrl & "MaxPerPage=" & xMaxPerPage & "&Page=" &

xPageCount & """ title=""末页"" class=""LastPage"">末页</a>"&vbcrlf
      Else
       PageStr = PageStr &

"&nbsp;<font color='#999999'><a class=""NextPage"">下一页</a></font>"
       PageStr = PageStr &

"&nbsp;<font color='#999999'><a class=""LastPage"">末页</a></font>"
      End If
      PageStr = PageStr &

"&nbsp;<input type=""text"" size='4' name=""MaxPerPage"" maxlength=""2""

value=""" & xMaxPerPage & """ onKeyPress=""if (event.keyCode==13)

window.location.href='" & strUrl & "MaxPerPage='+this.value;"">&nbsp;" &

xUnitName & "/页"&vbcrlf
      PageStr = PageStr & "&nbsp;

转到:<select id=""page"" class=""PageSelect""

onchange=""window.location.href='" & strUrl & "MaxPerPage=" & xMaxPerPage &

"&Page='+this.options[this.selectedIndex].value"">"&vbcrlf
      For i=1 To xPageCount
       PageStr = PageStr &

"    <option value=""" & i & """"
       If i = xCurrentPage

Then PageStr = PageStr & " selected"
       PageStr = PageStr &

">第" & i & "页</option>"&vbcrlf
      Next
      PageStr = PageStr & " 

</select>"&vbcrlf
      PageStr = PageStr &

"</div>"&vbcrlf
     Case "6" '分页样式5:显示首页

、上一页、下一页、末页,数字页和转向文本框
      PageStr = PageStr & "<div

id=""ShowPage"">"
      PageStr = PageStr & "<a

class=""TotalPage"">全部"&xPageName&":<b>" & xTotalNum &"</b>" & xUnitName

& "</a>"
      PageStr = PageStr &

"&nbsp;<a class=""PageInfo"">页次:<b>" & xCurrentPage & "/" & xPageCount &

"</b></a>"
      PageStr = PageStr &

"&nbsp;<a class=""TotalPage"">"&xMaxPerPage&xUnitName&"/页</a>"
      p = (xCurrentPage - 1) 10
      If xCurrentPage = 1 Then
       PageStr = PageStr &

"&nbsp;<a class=""FirstPage"">|&lsaquo;</a>"
      Else
       PageStr = PageStr &

"&nbsp;<a href=""" & strUrl & "Page=1"" title=""首页""

class=""FirstPage"">|&lsaquo;</a>"
      End If
      If p * 10 > 0 Then
       PageStr = PageStr &

"&nbsp;<a href=""" & strUrl & "Page=" & xCurrentPage - 10 & """ title=""上十

页"" class=""PrevPage"">&laquo;</a>"
      End If
      For i=(p * 10 + 1) To (p *

10 + 10)
       If i = xCurrentPage

Then
        PageStr =

PageStr & "&nbsp;[<font color='red'><a class=""CurrentPage"">" & i &

"</a></font>]"
       Else
        PageStr =

PageStr & "&nbsp;[<a href=""" & strUrl & "Page=" & i & """ title=""转到第" &

i & "页"" class=""GoToPage"">" & i & "</a>]"
       End If
       If i = xPageCount

Then Exit For
      Next
      If i < xPageCount Then

PageStr = PageStr & "&nbsp;<a href=""" & strUrl & "Page=" & i & """ title=""

下十页"" class=""NextPage"">&raquo;</a>"
      If xCurrentPage = xPageCount

Then
       PageStr = PageStr &

"&nbsp;<a class=""LastPage"">&rsaquo;|</a>"&vbcrlf
      Else
       PageStr = PageStr &

"&nbsp;[<a href=""" & strUrl & "Page=" & xPageCount & """ title=""末页""

class=""LastPage"">&rsaquo;|</a>]"&vbcrlf
      End If
      PageStr = PageStr & "&nbsp;

转到:<input id=""page"" size='4' type=""text"" value=""" & xCurrentPage &

""" maxlength=""4"" title=""定页"" onmouseover=""javascript:this.focus

();this.select()"" onKeyDown=""javascript: if(window.event.keyCode == 13)

window.location.href='" & strUrl & "Page='+this.value"">页"&vbcrlf

      PageStr = PageStr &

"</div>"&vbcrlf

    End Select
   End If
  Else
   PageStr = " "&vbcrlf
  End If
  ShowPage = PageStr
 End Function

 
End Class
%>

时间: 2024-10-15 17:13:13

asp 文章分页类的相关文章

简单好用的ASP.NET分页类(支持AJAX、自定义文字)

  这篇文章主要介绍了简单好用的ASP.NET分页类(支持AJAX.自定义文字),本文直接给出实现代码和使用方法,需要的朋友可以参考下 在做网站没用 JS UI控件时 很实用 用法: ? 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 var ps=new PageString();   /*可选参数*/   ps.SetIsEnglish = true;// 是否是英文 (默认:false) ps.SetIsShowText = true;//是

ASP通用分页类

分页 一.类的属性.方法 这是一个ASP通用分页类.你可以用它方便的给记录集分页,当然在网上有许多的分页类和分页函数.本分页主要有GetConn.GetRS.SQL.URL.CSSFile.FldName.FldNote.FldWidth.FldAlign.ShowPageType.TleFTColor.TleWidth.PageSize.ShowWidth.Init.Pages.ShowData.Close等属性和方法. 1.GetConn属性:用来获取一个已创建的Connection对象.

ASP经典分页类_应用技巧

ASP经典分页类  出处      '===================================================================== 'XDOWNPAGE   ASP版本 '版本   1.00 'Code by  zykj2000 'Email:   zykj_2000@163.net 'BBS:   http://bbs.513soft.net '本程序可以免费使用.修改,希望我的程序能为您的工作带来方便 '但请保留以上请息 ' '程序特点 '本程序

创建一个ASP通用分页类

创建|分页 转自"蓝色理想" http://www.blueidea.com/tech/program/2004/1989.asp.ASP分页一直是一个众说纷坛的话题,而且也没有一个太有效的方法.今天在CSDN的BLOG里看到了这个ASP分页类,(http://blog.csdn.net/xiangbo520/archive/2004/09/22/113539.aspx),只是提供了源码,而且源码中部分标签已被作为HTML显示了,想复制下来也不太容易,所有到蓝色理想找到了一篇全面一点的

创建一个ASP通用分页类_ASP CLASS类

从开始学习到使用ASP到现在也写了不少程序了,最令人头痛的是写数据分页,每次都是由于几个变量名或几个参数的不同,因而需要每次都写哪一段冗长而又繁杂的分页代码,代码长了使得程序的可读性变差,容易出差,调试半天也找不出错在哪里,所以慢慢的我开始使用一些网上的提供的分页函数或分页类.的确省事不少,但是通常的函数和类的做法都是就数据显示部分也封装了起来,每次为了达到自己需要的显求效果要去改动函数或者类的本身,所以使用起来也不是怎么方便,自己写的分页改起来已经够复杂了,更不要说别人的了. 所以趁昨天有空自

简单好用的ASP.NET分页类(支持AJAX、自定义文字)_实用技巧

在做网站没用 JS UI控件时 很实用 用法: var ps=new PageString(); /*可选参数*/ ps.SetIsEnglish = true;// 是否是英文 (默认:false) ps.SetIsShowText = true;//是否显示分页文字 (默认:true) //ps.TextFormat="" (默认值:<span class=\"pagetext\"><strong>总共</strong>:{0

asp 通用分页类

<%@LANGUAGE = "VBScript" CODEPAGE="936"%> <%Option Explicit%> <!--#include file="Cls_PageView.asp"--> Class Cls_PageView  Private sbooInitState  Private sstrPageUrl  Private sstrPageVar  Private sstrSql  Pri

ASP通用分页类源码

分页 <%'==================================================================='XDOWNPAGE ASP版本'版本 1.00'Code by zykj2000'Email: zykj_2000@163.net'BBS: http://bbs.513soft.net'本程序可以免费使用.修改,希望我的程序能为您的工作带来方便'但请保留以上请息''程序特点'本程序主要是对数据分页的部分进行了封装,而数据显示部份完全由用户自定义,'

创建一个ASP通用分页类(二)代码部分

创建|分页 <%'====================================================================='XDOWNPAGE ASP版本'版本 1.00'Code by zykj2000'Email: zykj_2000@163.net'BBS: http://bbs.513soft.net'本程序可以免费使用.修改,希望我的程序能为您的工作带来方便'但请保留以上请息''程序特点'本程序主要是对数据分页的部分进行了封装,而数据显示部份完全由用户