一个ASP分页的代码例子
<%’’本程序文件名为:Pages.ASP%>
<%’’包含ADO常量表文件adoVBs.inc,可从"\Program Files\Common Files\System\ADO"目录下拷贝%>
<!--#Include File="adovbs.inc"-->
<%’’*建立数据库连接,这里是Oracle8.05数据库
Set conn=Server.CreateObject("ADODB.Connection")
conn.Open "Provider=msdaora.1;Data Source=YourSrcName;User ID=YourUserID;Password=YourPassword;"
Set rs=Server.CreateObject("ADODB.Recordset") ’’创建Recordset对象
rs.CursorLocation=adUseClient ’’设定记录集指针属性
’’*设定一页内的记录总数,可根据需要进行调整
rs.PageSize=10
’’*设置查询语句
StrSQL="Select ID‚姓名‚住址‚电话 from 通讯录 Order By ID"
rs.Open StrSQL‚conn‚adOpenStatic‚adLockReadOnly‚adCmdText
%>
<HTML>
<HEAD>
<title>分页示例</title>
<script language=JavaScript>
//点击"[第一页]"时响应:
function PageFirst()
{
document.MyForm.CurrentPage.selectedIndex=0;
document.MyForm.CurrentPage.onchange();
}
//点击"[上一页]"时响应:
function PagePrior()
{
document.MyForm.CurrentPage.selectedIndex--;
document.MyForm.CurrentPage.onchange();
}
//点击"[下一页]"时响应:
function PageNext()
{
document.MyForm.CurrentPage.selectedIndex++;
document.MyForm.CurrentPage.onchange();
}
//点击"[最后一页]"时响应:
function PageLast()
{
document.MyForm.CurrentPage.selectedIndex=document.MyForm.CurrentPage.length-1;
document.MyForm.CurrentPage.onchange();
}
//选择"第?页"时响应:
function PageCurrent()
{ //Pages.asp是本程序的文件名
document.MyForm.action=’Pages.asp?Page=’+(document.MyForm.CurrentPage.selectedIndex+1)
document.MyForm.submit();
}
</Script>
</HEAD>
<BODY bgcolor="#ffffcc" link="#008000" vlink="#008000" alink="#FF0000"">
<%IF rs.Eof THEN
Response.Write("<font size=2 color=#000080>[数据库中没有记录!]</font>")
ELSE
’’指定当前页码
If Request("CurrentPage")="" Then
rs.AbsolutePage=1
Else
rs.AbsolutePage=CLng(Request("CurrentPage"))
End If
’’创建表单MyForm‚方法为Get
Response.Write("<form method=Get name=MyForm>")
Response.Write("<p align=center><font size=2 color=#008000>")
’’设置翻页超链接
if rs.PageCount=1 then
Response.Write("[第一页] [上一页] [下一页] [最后一页] ")
else
if rs.AbsolutePage=1 then
Response.Write("[第一页] [上一页] ")
Response.Write("[<a href=Javascript:PageNext()>下一页</a>] ")
Response.Write("[<a href=javascript:PageLast()>最后一页</a>] ")
else
if rs.AbsolutePage=rs.PageCount then
Response.Write("[<a href=javascript:PageFirst()>第一页</a>] ")
Response.Write("[<a href=javascript:PagePrior()>上一页</a>] ")
Response.Write("[下一页] [最后一页] ")
else
Response.Write("[<a href=javascript:PageFirst()>第一页</a>] ")
Response.Write("[<a href=javascript:PagePrior()>上一页</a>] ")
Response.Write("[<a href=javascript:PageNext()>下一页</a>] ")
Response.Write("[<a href=javascript:PageLast()>最后一页</a>] ")
end if
end if
end if
’’创建下拉列表框,用于选择浏览页码
Response.Write("第<select size=1 name=CurrentPage onchange=PageCurrent()>")
For i=1 to rs.PageCount
if rs.AbsolutePage=i then
Response.Write("<option selected>"&i&"</option>") ’’当前页码
else
Response.Write("<option>"&i&"</option>")
end if
Next
Response.Write("</select>页/共"&rs.PageCount&"页 共"&rs.RecordCount&"条记录</font><p>")
Response.Write("</form>")
’’创建表格,用于显示
Response.Write("<table align=center cellspacing=1 cellpadding=1 border=1")
Response.Write(" bordercolor=#99CCFF bordercolordark=#b0e0e6 bordercolorlight=#000066>")
Response.Write("<tr bgcolor=#ccccff bordercolor=#000066>")
Set Columns=rs.Fields
’’显示表头
For i=0 to Columns.Count-1
Response.Write("<td align=center width=200 height=13>")
Response.Write("<font size=2><b>"&Columns(i).name&"</b></font></td>")
Next
Response.Write("</tr>")
’’显示内容
For i=1 to rs.PageSize
Response.Write("<tr bgcolor=#99ccff bordercolor=#000066>")
For j=0 to Columns.Count-1
Response.Write("<td><font size=2>"&Columns(j)&"</font></td>")
Next
Response.Write("</tr>")
rs.movenext
if rs.EOF then exit for
Next
Response.Write("</table>")
END IF
%>
</BODY>
</HTML>
- 数据库实现显示、添加、修改、删除的最简单的方法及实例2006-3-2
- 用ASP建立站内搜索2006-3-2
- 利用ASP打造站内搜索引擎2006-3-2
- asp 查看服务器文件2006-3-2
- blog的rss2.0 2006-3-2
- 一个ASP分页的代码例子2006-3-2
- 一个通用的保护ASP系统的方法2006-3-2
- asp判断函数一览及网页制作常用技(2)2006-3-2
- asp判断函数一览及网页制作常用技(1)2006-3-2
- 菜鸟十天学会ASP教程之第一天:安装调试ASP的环境[图]2006-3-2
![清风楼书(一)[图]--平面广告](http://www.fansart.com/uploadfile/200642868655905.gif)
清风楼书(一)
![painter超级可爱的上色过程(韩国)[图]--CG插画](http://www.fansart.com/uploadfile/200641150378565.jpg)
painter超级可爱的上色过程(韩国)
![古典楼书(精品欣赏)(1)[图]--平面广告](http://www.fansart.com/uploadfile/200641153842877.jpg)
古典楼书(精品欣赏)(1)
![美国插画师kevindart作品(1)[图]--CG插画](http://www.fansart.com/uploadfile/200641156499109.jpg)
美国插画师kevindart作品(1)
![美国插画师kevindart作品[图]--CG插画](http://www.fansart.com/uploadfile/200641156355093.jpg)
美国插画师kevindart作品

荷兰著名画家Anton Pieck插画
![非常可爱的儿童插画(1)[图]--CG插画](http://www.fansart.com/uploadfile/200641157447221.jpg)
非常可爱的儿童插画(1)
![回忆紫禁城里那些逝去的[图]--中国艺术](http://www.fansart.com/uploadfile/200641159463469.jpg)
回忆紫禁城里那些逝去的
![国粹京剧脸谱表情[图]--界面设计](http://www.fansart.com/uploadfile/200641164370797.jpg)
国粹京剧脸谱表情
![高傲的玫瑰-温碧霞[图]--摄影艺术](http://www.fansart.com/uploadfile/200641232299455.jpg)
高傲的玫瑰-温碧霞
![北邦插画欣赏(1)[图]--CG插画](http://www.fansart.com/uploadfile/200641335800545.jpg)
北邦插画欣赏(1)
![yashasi插画作品欣赏[图]--CG插画](http://www.fansart.com/uploadfile/200641366906025.jpg)
yashasi插画作品欣赏
![cg插画欣赏[图]--CG插画](http://www.fansart.com/uploadfile/200641433658593.jpg)
cg插画欣赏
![溯源居广告欣赏--小红人[图]--平面广告](http://www.fansart.com/uploadfile/200641453136345.jpg)
溯源居广告欣赏--小红人
![房地产广告设计-之水墨风格1[图]--平面广告](http://www.fansart.com/uploadfile/200641457308753.jpg)
房地产广告设计-之水墨风格1
![泊林花园推广故事绘本(1)[图]--CG插画](http://www.fansart.com/uploadfile/200642041664949.jpg)
泊林花园推广故事绘本(1)
![泊林花园推广故事绘本(2)[图]--CG插画](http://www.fansart.com/uploadfile/200642042197577.jpg)
泊林花园推广故事绘本(2)
![万科西山庭院.格.沉.尊[图]--平面广告](http://www.fansart.com/uploadfile/200642133015939.jpg)
万科西山庭院.格.沉.尊
![2006夏日流行时尚,创意无限街头华丽[图]--时装魅影](http://www.fansart.com/uploadfile/200642261089093.jpg)
2006夏日流行时尚,创意无限街头华丽
![水木清华地产广告欣赏[图]--平面广告](http://www.fansart.com/uploadfile/200642634295921.jpg)
水木清华地产广告欣赏