请高手给点思路:一条记录里的长文章分页显示!
要求:
select数据库里(asp+access)的一条记录内容分页显示,应该用什么方式比较好,如果按字符长度分页的话如何避免记录里的中英文或html信息不被中间截断。
比如:一个汉字被截成两半,或一条html语句截成两半。
请高手指点!
谢谢!
------解决方案-------------------- <%
'==============自动分页类===================
Class aspxsky_page
Private Sub class_initialize
End Sub
Public Function Alert(message,gourl)
message = replace(message, " ' ", "\ ' ")
If gourl= "-1 " then
Response.Write ( " <script language=javascript> alert( ' " & message & " ');history.go(-1) </script> ")
Else
Response.Write ( " <script language=javascript> alert( ' " & message & " ');location= ' " & gourl & " ' </script> ")
End If
Response.End()
End Function
Public Sub showpage(str,page,url)
if not isnumeric(page) then
alert "提示:错误的参数! ", "-1 "
end if
if page= " " or page=0 or isnull(page) or isempty(page) then
page=1
else
page=cint(page)
end if
str=split(str, "$nextpage$ ")
abspage=page
pcount=ubound(str)+1
if page> cint(ubound(str)+1) or page <1 then
alert "提示:错误的参数! ", "-1 "
else
'response.write str(page-1)& " <br> <br> <center> 共分为 "&pcount& "页 "
response.write str(page-1)& " <br> <br> <center > "
end if
if ubound(str) <> 0 then
for p=0 to ubound(str)
if p=abspage-1 then
response.write "[ "&p+1& "] "
else
response.write " <a href= "&url& "p= "&p+1& "> [ "&p+1& "] </a> "
end if
next
end if
' response.write "当前第 "&abspage& "/ "&pcount& "页 </center> "
response.write " </center> "
End Sub
End Class
%>
调用方法:
<%
p=request.QueryString( "p ")
url= "show.asp?id= "&news_id& "& "
set newpage=new aspxsky_page
newpage.showpage(sContent,p,url)
%>