ASP高性能分页程序

2008-02-23 09:40:43来源:互联网 阅读 ()

新老客户大回馈,云服务器低至5折

<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>&nbsp;&nbsp;&nbsp;</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> | 第&nbsp;<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;">&nbsp;页 <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>
<!--## 分页前台显示代码段结束 ##-->

标签:

版权申明:本站文章部分自网络,如有侵权,请联系:west999com@outlook.com
特别注意:本站所有转载文章言论不代表本站观点,本站所提供的摄影照片,插画,设计作品,如需使用,请与原作者联系,版权归原作者所有

上一篇:正则表达式快速入门教程

下一篇:ASP验证码的程序及原理