ASP长文章分页代码实例
来源:asp之家 发布时间:2007-10-02 17:04:00
标签:分页,长文章
ASP长文章分页代码实例,也许你会问一篇文章为什么还要进行分页呢?因为文章有短有长,当你的文章很长的时候,如果就一个页面都显示出来的话,读者一看文章这么长,他很可能放弃阅读,他会想这么长我要读到什么时候啊!而且密码麻麻的很容易吓到读者,呵呵!如果你给他分页了,比如1000个文字左右分了一页的话,给读者的心里感觉就不同了,他会不知不觉的阅读下去。
这里使用了文章分页标志:{nextpage}来进行长文章分页,当然你也可以换成其它你喜欢的标志符号,但是一定要注意你的分页标志不能太普通,否则在文章中一旦出现这个标志就会分一页了。
下面我说一下使用分页标志来进行长文章分页的原理,其实分页的原理也很简单,从数据库中读取含有分页标志的文章内容后(当然文章短的话就不用加分页标志了),利用asp的split函数把文章内容存入数组。显示的时候,就按顺序读取数组内容就可以了。
下面的程序基本可以满足动态页面的长文章分页使用了,程序来源网络。
<%
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&"页 "
end if
for p=0 to ubound(str)
response.write "<a href="&url&"p="&p+1&">["&p+1&"]</a> "
next
response.write "当前第"&abspage&"/"&pcount&"页</center>"
End Sub
End Class
调用方法:这里的str就是文章的内容,在实际使用时换成你文章的内容就可以了。p是页码
p=request.QueryString("p")
str="第一页:这里是第一页的内容{nextpage}第二页:这里是第二页的内容"
url="shownews.asp?id="&id&"&"
set newpage=new aspxsky_page
newpage.showpage str,p,url
当然知道了这个长文章分页的原理后,你完全可以自己试着写个程序,应该不会难的。
0
投稿
猜你喜欢
- f-string 格式化f-string 格式化 就是在字符串模板前面加上f,然后占位符使用{} ,里面直接放入对应的数据对象。如下所示f&
- 解决方法: 给 audio 组件绑定点击事件,手动触发播放暂停方法!代码片段:wxml文件<!-- 判断是语音通话,有通话记录,通话描
- 在项目里碰到需要把类似'450000'的数字转换为会计记账所用的格式,'450,000.00',分隔千分位和
- 1、demo第一个代码是多线程的简单使用,编写了线程如何执行函数和类。import threadingimport timeclass Cl
- UCD介绍UCD是Unicode字符数据库(Unicode Character DataBase)的缩写。UCD由一些描述Unicode字符
- 一、前言一首歌热门了,参与评论的人也很多,那我们有时候想看看评论,也只能看看热门的评论,大部分人都说的什么,咱也不知道呀~那本次咱们就把歌词
- Python字符串介绍字符串是一系列字符。在 Python 中,引号内的任何内容都是字符串。您可以使用单引号或双引号。例如:message
- SQL Server中的集合运算包括UNION(合并),EXCEPT(差集)和INTERSECT(相交)三种。集合运算的基本使用1.UNIO
- 使用pandas读xlsx文件读取前n行数据读取指定数据(指定行指定列)获取文件行号和列标题将数据转换为字典形式import pandas
- 找了国内30个比较著名的网站的注册表单做样本,对标签和输入区对齐方式做了统计,得到了一个结论:标签水平右对齐更适合中文网站,或者说右对齐更适
- 这些包可以独立使用,也可以与其他包一起使用以满足复杂的业务需求。Integration Services 可以提取和转换来自多种源(如 XM
- 回滚段管理一直是ORACLE数据库管理的一个难题,本文通过实例介绍ORACLE回滚段的概念,用法和规划及问题的解决。 回滚段概述 回滚段用于
- 不用库,写了很久,一直出bug,到网上一搜,可以直接输入之后,eval(str)即可得到结果!eval程序如下:s=input("
- Python 面向对象方法没有重载#在其他语言中,可以定义多个重名的方法,只要保证方法签名唯一即可。方法签名包含3个部分:方法名、参数数量、
- 本文主要讲解SQLite中时间函数进行分析与总结并给出使用案例。本文给出的例子都是经过测试。SQLite时间/日期函数种类:1、dateti
- 文件内容:excel内容:代码:import xlrdimport jsonimport operatordef read_xlsx(fil
- 1.先用 for 循环取for item in l: if isinstance(item ,list): &nb
- 当然可以,我们使用强大的fso对象来获取文件夹的大小请敲入如下代码即可:<%Set MyFileSize =&nb
- 一: 删除LOG1:分离数据库 企业管理器->服务器->数据库->右键->分离数据库2:删除LOG文件3:附加数据库 企业管理器->服务器-
- NOMONEYDAY123114321-45324212-102250331008为了符合阅读习惯,最终报表希望是如下格式:NOMONTUE