一、手动实现分页
在录入内容的时候在要分页的地方加入[NextPage]就可以了
<%
'==================================================
'过程名:listbody
'作 用:按要求显示文章内容
'参 数:body ------ 文章内容
'==================================================
Sub listbody(body)
dim arrbody,pages
if Instr(body,"[NextPage]")<=0 then
response.write body
'response.write "</p><p align='center'><font color='red'><b>[1]</b></font></p>"
else
CurPage=request("CurPage")
arrbody=split(body,"[NextPage]")
pages=Ubound(arrbody)+1
if CurPage="" then
CurPage=1
else
CurPage=Cint(CurPage)
end if
if CurPage<1 then CurPage=1
if CurPage>pages then CurPage=pages
response.write arrbody(CurPage-1)
response.write "<div align=center>"
for i=1 to pages
if i=Curpage then response.write "[<font color=red>"&i&"</font>] " else response.write "[<a href=?id="&request("id")&"&CurPage="&i&">"&i&"</a>] "
next
response.write "</div>"
end if
End Sub
%>
文章内容:<% call(listbody(rs("content")))%>
二、实现手动分页,自动分页
以下是几种文章内容过长实现的内容分页源代码.
'按标识手动分页
function manualPage(str)
pages=request.QueryString("page")
contentstr=split(str,"{$page$}")
Response.Write(ContentStr(pages))
Response.Write("<p/>")
Response.Write("<div class=""pageList"">")
For i = 0 to ubound(ContentStr)
Response.Write("<a href=’?ID="&request("id")&"&page="&i&"’>"&i+1&"</a> ")
Next
Response.Write("</div>")
end function
'按长度分页
function autoPage(str,fontnum)
if len(str)>fontnum then
if len(str) mod fontnum>0 then '计算总页数
pagecontent=len(str)\fontnum+1
else
pagecontent=len(str)\fontnum
end if
Dim arr()
ReDim arr(pagecontent)
for m = 1 to pagecontent
if m<>pagecontent then
arr(m)= mid(str,(m*fontnum-fontnum+1),fontnum)
else
arr(m)= mid(str,(m*fontnum-fontnum+1),len(str))
end if
next
if Request.QueryString("page")<>"" then
Response.Write(arr(Request.QueryString("page")))
else
Response.Write(arr(1))
end if
Response.Write("<p/>")
Response.Write("<div class=""pageList"">")
for i = 1 to pagecontent
Response.Write("<a href=?ID="&request("id")&"&page="&i&">"&i&"</a> ")
next
Response.Write("</div>")
else
Response.Write(str)
end if
end function
=============================
在页面中
<%
if Instr(Content,"{$page$}")=0 then ’判断是否是手工分页标志,不是就自动分页
call autoPage(Content,2000)
else
call manualPage(Content)
end if
%>
更多的asp录入文章太长分页代码请到论坛查看: http://BBS.TC711.COM
【 双击滚屏 】 【 评论 】 【 收藏 】 【 打印 】 【 关闭 】
来源:
互联网
日期:2009-2-28