ASP分页函数
2018-09-06 11:29
FunctionExportPageInfo(ByRefrs,curpage,i,LinkFile)
Dimretval,j,pageNumber,BasePage
retval=第curpage页/总rs.pagecount页
retval=retval本页i条/总rs.recordcount条
Ifcurpage=1Then
retval=retval首页前页
Else
retval=retval<ahref=’’LinkFilepage=1’’>首页</a><ahref=’’LinkFilepage=cstr(curpage-1)’’>前页</a>
EndIf
Ifcurpage=rs.pagecountThen
retval=retval后页末页
Else
retval=retval<ahref=’’LinkFilepage=cstr(curpage+1)’’>后页</a><ahref=’’LinkFilepage=cstr(rs.pagecount)’’>末页</a>
Endif
retval=retval<br/>
BasePage=(curpage10)*10
IfBasePage>0Thenretval=retval<ahref=’’LinkFilepage=(BasePage-9)’’><<</a>
Forj=1to10
pageNumber=BasePage+j
IfPageNumber>rs.pagecountThenExitFor
IfpageNumber=Cint(curpage)Then
retval=retval<fontcolor=’’#FF0000’’>pageNumber</font>
Else
retval=retval<ahref=’’LinkFilepage=pageNumber’’>pageNumber</a>
EndIf
Next
Ifrs.pagecount>BasePageThenretval=retval<ahref=’’LinkFilepage=(BasePage+11)’’>>></a>
ExportPageInfo=retval
EndFunction
应用
<%
adoPageRS.openSELECT*FROMnewsORDERBYaddtimeDESC,conn,1,1
iferr.number<>0then
response.write数据库操作失败:err.description
else
ifadoPageRS.eofandadoPageRS.bofthen
response.write没有记录
else
%>
<palign=center>
<center>
<tablewidth=100%border=0cellspacing=1cellpadding=2>
<trclass=big>
<tdwidth=60%>新闻标题</td>
<tdwidth=25%align=center>日期</td>
<tdwidth=15%align=center>操作</td>
</tr>
<%
adoPageRS.pagesize=10
adoPageRS.absolutepage=curpage
fori=0to9
%>
<tr>
<td><%=adoPageRS(title)%></td>
<tdalign=center>
<%=adoPageRS(addtime)%>
</td>
<tdalign=center><ahref=’’newsman.asp?action=editid=<%=adoPageRS(id)%>’’>编辑</a>
<ahref=’’javascript:confirmDel(<%=adoPageRS(id)%>)’’>删除</a></td>
</tr>
<%
adoPageRS.movenext
ifadoPageRS.eofthen
i=i+1
exitfor
EndIf
next
%>
<tralign=center>
<tdcolspan=3>
<%=ExportPageInfo(adoPageRS,curpage,i,Newsman.asp?)%>
</td>
</tr>
</table>
</center>
</p>