ASP分页

分页

本人写了2个通用的ASP分页方法,供大家参考!
<%@ Language=VBScript %>
<HTML>
<HEAD>
</HEAD>
<BODY>

<%
dim currentpage  '定义当前页
dim filename     '文件名
Const MaxPerPage=20   '每页显示的记录个数
dim totalnumber  '记录总数
filename="showpages.asp"
totalnumber=200     '设置记录总数为200

if not isempty(request("page")) then
      currentPage=cint(request("page"))
   else
      currentPage=1
end if
showpages totalnumber,MaxPerPage,filename
%>
</BODY>
</HTML>
<%'定义分页的函数,以totalnumber,maxperpage,filename作为函数的入口。
function showpages(totalnumber,maxperpage,filename)
  dim n
  if totalnumber mod maxperpage=0 then
     n= totalnumber maxperpage
  else
     n= totalnumber maxperpage+1
  end if
  response.write "<form method=Post action="&filename&">"
  response.write "<p align='center'>记录分页 "
  if CurrentPage<2 then
    response.write "<font color='999966'>首页 上一页</font> "
  else
    response.write "<a href="&filename&"?page=1>首页</a> "
    response.write "<a href="&filename&"?page="&CurrentPage-1&">上一页</a> "
  end if
  if n-currentpage<1 then
    response.write "<font color='999966'>下一页 尾页</font>"
  else
    response.write "<a href="&filename&"?page="&(CurrentPage+1)
    response.write ">下一页</a> <a href="&filename&"?page="&n&">尾页</a>"
  end if
   response.write " 页次:<strong><font color=red>"&CurrentPage&"</font>/"&n&"</strong>页  "
   response.write " 转到:<input type='text' name='page' size=4 maxlength=10 class=smallInput

value="&currentpage&">"
   response.write "<input class=buttonface type='submit'  value=' Goto '  name='cndok'></span></p></form>"
      
end function
%>

--------------------------------------------------------------------------

<%@ Language=VBScript %>
<HTML>
<HEAD>
</HEAD>
<BODY>

<%
dim currentpage  '定义当前页
dim filename     '文件名
Const MaxPerPage=20   '每页显示的记录个数
dim totalnumber  '记录总数
filename="showpages.asp"
totalnumber=200     '设置记录总数为200

if not isempty(request("page")) then
      currentPage=cint(request("page"))
   else
      currentPage=1
end if
showpages totalnumber,MaxPerPage,filename
%>
</BODY>
</HTML>
<%'定义分页的函数,以totalnumber,maxperpage,filename作为函数的入口。
function showpages()
    dim n
    if (totalnumber mod MaxPerPage)=0 then
       n= totalPut MaxPerPage
    else
       n= totalPut MaxPerPage + 1
    end if
    if n=1 then
        exit sub
    end if
    dim k
    response.write "<p align='left'>>> 分页 "
      for k=1 to n
        if k=currentPage then
   response.write "[<b>"+Cstr(k)+"</b>] "
else
  response.write "[<b>"+"<a href="&filename&"?page="+cstr(k)+">"+Cstr(k)+"</a></b>] "
        end if
      next
    response.write "</p>"
   end function
%>

时间: 2024-08-23 01:20:09

ASP分页的相关文章

ASP分页祥解

分页 关于ASP分页的问题,对于初学者是一个比较重要的问题,也是各个网站运用最为广泛的技术,下面我就把我总结的一点小经验介绍给大家(写的不好,请大家指点)1.原理:ASP分页其实是将数据库中的记录分割成若干段"分屏显示",为什么叫"分屏显示"显示,因为其实显示的原始页面只有1页,通过控制数据库显示,来刷新页面的显示内容(可能一些朋友会误会为动态产生若干页面来显示,呵呵,我刚刚学的时候也是这样以为的)2.用到的几个函数rs.pagesize--->定义一页显示记

两个高效的ASP分页函数

两个高效的ASP分页函数(统计记录数,分页提取记录) <% '    /*智能返回分页SQL语句*/ '    /// <summary> '    /// 功能:智能返回分页SQL语句 '    /// </summary> '    /// <param name="primaryKey">主键(不能为空)</param> '    /// <param name="queryFields">提取

2个通用的ASP分页方法(数字形式和文字形式)

本人写了2个通用的ASP分页方法,供大家参考! <%@ Language=VBScript %> <HTML> <HEAD> </HEAD> <BODY> <% dim currentpage   '定义当前页 dim filename     '文件名 Const MaxPerPage=20 '每页显示的记录个数 dim totalnumber   '记录总数 filename="showpages.asp" tota

2个通用的ASP分页方法

分页 本人写了2个通用的ASP分页方法,供大家参考!<%@ Language=VBScript %><HTML><HEAD></HEAD><BODY> <%dim currentpage  '定义当前页dim filename     '文件名Const MaxPerPage=20   '每页显示的记录个数dim totalnumber  '记录总数filename="showpages.asp"totalnumber=

ASP 分页操作, 改良版

分页 效果:首页 上十 上一 11 12 13 14 15 16 17 18 19 20 下一 下十 尾页 转到___  11/20页  963篇 主文件: dateview.asp , 查询参数 yearview=, 分页参数 pageview=包含文件: abbr.asp dateview.asp?yearview=2004&pageivew=1---/------------------------------------------------------------------- <

ASP 分页技巧

分页|技巧 效果首页 上十 上一 1 2 3 4 5 6 7 8 9 10  下一 下十 尾页 转到___页数:1/25页  篇数:125 主文件 nclass.asp包含文件 top.asp || bottom.asp || abbrword.asp || conn.asp 内容 ---/----------------------------------------------------------- nclass.asp <%@LANGUAGE="VBSCRIPT" CO

asp分页的一个类

分页 asp分页的一个类, 在50,000条记录下测试过,速度比ado的那个要快多了 <% '************************************************************************************'具体用法'Set conn=Server.CreateObject("ADODB.Connection")'conn.open "DRIVER={SQL Server};SERVER=(local);UID=s

实例参考:asp分页生成html程序

参考|程序|分页|生成html 这是一个asp分页列表生成静态页面得asp小程序<!--#include file="conn.asp"--><html><head><TITLE>分页测试</TITLE><LINK href="inc/style.css" type=text/css rel=stylesheet></head><%strHead=strHead&&qu

asp分页的基于对象的解决

对象|分页|解决 在论坛上有不少的关于asp分页的文章,基本思想是一致的,我把这些网友的思路深化了一下,用javaScript套上了一层基于对象的外衣,这样调用起来就不显得乱了,其它的话就不多说了,详见程序中的注释. 下边是源程序:<script language=javascript runat=server> function trim(str)//去掉字符串的首尾空格 { var tmpStr=new String(str) return tmpStr.replace(/(^\s*)|(