ASP 分页问题,高手请进

来源:百度知道 编辑:UC知道 时间:2024/05/26 02:09:36
<%sub showpage(sfilename,totalnumber,maxperpage,ShowTotal,ShowAllPages,strUnit)
dim n, i,strTemp,strUrl
if totalnumber mod maxperpage=0 then
n= totalnumber \ maxperpage
else
n= totalnumber \ maxperpage+1
end if
strTemp= "<table align='center'><form name='showpages' method='Post' action='" & sfilename & "'><tr><td>"
if ShowTotal=true then
strTemp=strTemp & "共 <b>" & totalnumber & "</b> " & strUnit & "  "
end if
strUrl=JoinChar(sfilename)
if CurrentPage<2 then
strTemp=strTemp & "首页 上一页 "
else
strTemp=strTemp & "<a href='" & strUrl & "page=1'>首页</a> "
strTemp=strTemp & "<a href='" & strUrl & "page=" & (CurrentPage-1) & "'>上

可以, 例子中总页数是n, 当前页是CurrentPage,用个循环就可以了

<%
sub showpage(sfilename,totalnumber,maxperpage,ShowTotal,ShowAllPages,strUnit)
dim n, i,strTemp,strUrl

'这里应该有对strUrl的定义.......

if totalnumber mod maxperpage=0 then
n= totalnumber \ maxperpage
else
n= totalnumber \ maxperpage+1
end if

strTemp=""
for i = 1 to n
if i = CurrentPage then
strTemp = strTemp & " <font color=red>" & i & "</font> "
else
strTemp = strTemp & " <a href='" & strUrl & "?page=" & i & "'>" & i & "</a> "
end if
response.write strTemp
end sub
%>

这是直接从1到最后全部显出来, 至于怎么只显示一部分, 如当前页在1-10页时, 显示1-10的页链接, 在11-20时, 显示11-20页的链接. 这些就自己看着改吧.

应该能,但在网页头部应该还有代码的.