ASP高性能分页程序
<table width="100%" border="0" cellpadding="0" cellspacing="1" bgcolor="#CCCCCC">
<%
SQL="Select ID From News Order By ID Desc"
SQLA="Select Title,FilePath,FileName From News where ID In "
SQLB=" Order By ID Desc"
rs.Open SQL,conn,1,1
ThePageCount=1
CurrentPage=1
ToPage=1
If Not rs.Eof Then
'##分页处理开始
ThePageSize=120
rs.PageSize=ThePageSize
ThePageCount=rs.PageCount
GetToPage=Request.Querystring("ToPage")
IF Not IsNumEric(GetToPage) or InStr(GetToPage,".") Then
rs.AbsolutePage=1
Else
IF Cint(GetToPage)<=1 Then
ToPage=1
rs.AbsolutePage=1
ElseIF Cint(GetToPage)>=ThePageCount Then
ToPage=rs.PageCount
rs.AbsolutePage=ThePageCount
Else
ToPage=GetToPage
rs.AbsolutePage=GetToPage
End IF
End IF
'##分页处理结束
i=0
PageListNumber=0
PageSQL="("
While Not rs.Eof and i<ThePageSize
PageSQL=PageSQL&rs(0)&","
rs.MoveNext
i=i+1
PageListNumber=PageListNumber+1
Wend
rsClose
PageSQL=PageSQL&"0)"
'Response.Write PageSQL
Set rs=Conn.ExeCute(SQLA&PageSQL&SQLB)
i=1
t=1
While Not rs.Eof
IF t mod 2=0 Then
BackGroundColor="FFFFFF"
Else
BackGroundColor="F7F7F7"
End IF
IF i=1 Then
Response.Write "<tr bgcolor=""#FFFFFF"">"
End IF
%>
<td height="26" width="25%">・<a href="NewsContent<%Response.Write rs(1)&rs(2)%>" target=_blank><%Response.Write rs(0)%></a></td>
<%
IF i mod 4 = 0 Then
t=t+1
Response.Write "</tr>"
End IF
IF (i mod 4 = 0) and i<>ThePageSize Then
Response.Write "<tr bgcolor=""#"&BackGroundColor&""">"
End IF
IF (i mod 4 <>0) and i=PageListNumber Then
For x=1 to (4-(i mod 4))
Response.Write "<td> </td>"
Next
Response.Write "</tr>"
End IF
i=i+1
rs.MoveNext
Wend
rs.Close
Set rs=Nothing
Else
End IF
%>
</table>
<!--## 分页前台显示代码段开始 ##-->
<table width=100%>
<form action="" method=get>
<tr><td height=40 valign=middle align=center>
共 <%=ThePageCount%> 页 | <a href = ?ID=<%=ID%>>首页</a> |
<%IF ToPage > 1 Then%>
<a href = ?ID=<%=ID%>&ToPage=<%=ToPage-1%>>上一页</a>
<%Else%>
上一页
<%End IF%>
|
<%
CurrentPage=Cint(ToPage)
if Cint(ToPage)<Cint(ThePageCount) then
ToPage = Cint(ToPage) + 1
%>
<a href = ?ID=<%=ID%>&ToPage=<%=ToPage%>>下一页</a>
<%Else%>
<font style='color:#999999'>下一页</font>
<%End IF%>
| <a href = ?ID=<%=ID%>&ToPage=<%=ThePageCount%>>末页</a> | 第 <input type=text name="ToPage" value="<%=CurrentPage%>" size=4 maxlength=5 style="BORDER-RIGHT: silver 1px solid #aaaaaa; BORDER-TOP: silver 1px solid; BORDER-LEFT: silver 1px solid; background-color:ffffff; height:13pt;width:20pt; COLOR: black; border-color:#aaaaaa; border-bottom: silver 1px solid #aaaaaa;font-size:9pt;"> 页 <input type=submit value="跳转" style="border-right: #cccccc 1px groove; font-weight: normal;font-size: 9pt; height:14pt;line-height: normal; border-bottom: #cccccc 1px groove; font-style: normal; background-color: #eeeeee; font-variant: normal"></td></tr>
<!--隐藏值传递
<input type=hidden name="" value="">
隐藏值传递-->
<input type=hidden name="ID" value="<%=ID%>">
</form>
</table>
<!--## 分页前台显示代码段结束 ##-->
- 上一篇: ASP实用技巧:强制刷新和判断文件地址
- 下一篇: ASP分页显示Recordset数据