asp分页显示

2016 年 7 月 13 日5300

asp分页显示

在需要显示页码的页面:

page=cint(request("page")) 'page是url中页码的参数
querys="..." '定义url的其他参数

rs.PageSize=30 '每页条数,自己设定
dim pagecount=rs.PageCount
rs.AbsolutePage=pageno

if pagecount>1 then
response.write("分页: ")
outpages pagecount,page''''''此处'显示页码,函数见后
response.write "<br><br>"
end if


dim showcount=0
do while (not rs.eof and showcount<rs.PageSize )
显示每条内容
showcount=showcount+1
rs.movenext
loop

'以下为显示页码的函数,可单独放在一个文件中:

sub outpages(pagecount,curpage)

yyy=int((curpage-1)/10)
startno=yyy*10+1
endno=startno+10-1


if startno<1 then startno=1
if endno>pagecount then endno=pagecount

response.write "<b>"

if startno>1 then
response.write "&nbsp;&nbsp;<a target=_top href=?"&querys&"&page="&(startno-10)&"><<</a>&nbsp;&nbsp;"
end if


for j=startno to endno
if j=page then
response.write " "&j&"&nbsp;&nbsp;"
else
response.write " <a target=_top href='"
response.write "?"&querys&"&page="&j
response.write "'>["&j&"]</a>&nbsp;&nbsp;"
end if
next


if pagecount>endno then
response.write "&nbsp;&nbsp;<a target=_top href=?"&querys&"&page="&(endno+1)&">>></a>"
end if

response.write "</b>"


end sub

0 0