ASP生成静态分页显示

diplodocus 2009-02-03 12:01:53
下面的代码,在生成静态新闻列表分页的时候。生成页数正常,但是每页的内容都一样。。找了好久都不知道原因出在哪。。。
哪位高手能帮帮小弟解决问题吗


dim page,maxPerPage,addr
dim tpl,curl
Set tpl = New ClsTemplate '实例化模板类
tpl.setfile(server.mappath("../templets/Content_List.html"))
set rsz=server.createobject("adodb.recordset")
objStr="select * from [article] order by ID desc"
rsz.open objStr,Conn,1,1
maxPerPage=1 '每页显示的记录数
strContent = ""
if rsz.eof then
'tpl.newKey是一个模板类里面替换标签的函数.用法:tpl.newKey "标签名","替换后内容"
tpl.newKey "WebUrl",WebConfig("WebUrl",1)
tpl.newKey "WebUrl1",WebConfig("WebUrl",2)
tpl.newKey "WebUrl2",WebConfig("WebUrl",3)
tpl.newKey "WebTitle",T_TYPE2
tpl.newKey "keywords",WebConfig("WebKeyWords",Topic+1)
tpl.newKey "pro_class_lb",ProductsClass("lb")
tpl.newKey "pro_class_pp",ProductsClass("pp")
tpl.newKey "description",WebConfig("Description",Topic+1)
tpl.newKey "footer",WebConfig("footer",1)
tpl.newKey "fpage","暂无记录"
tpl.newKey "str_content",strContent

'tpl.out_file 生成静态文件
tpl.out_file "../News/Index.html",tpl.gettext()
Response.Write("<hr><b>成功生成News/Index.html</b>")
else
rsz.pagesize=MaxPerPage
PageCounts=rsz.pagecount
for ii=1 to PageCounts
rsz.pagesize=MaxPerPage
rsz.absolutepage=ii

ni = 0
do while (ni<maxPerPage)
strContent = strContent &"<div class=""box"">"&vbcrlf
strContent = strContent &" <dl class=""cnt_list"">"&vbcrlf
strContent = strContent &"<dt><a href="""&rsz("curl")&"""><img src="""&rsz("Simg")&""" width=""90"" height=""100"" border=""0"" /></a></dt>"&vbcrlf
strContent = strContent &"<dd style=""font-weight:bold"">"&vbcrlf
strContent = strContent &"<a href="""&rsz("curl")&""">"&rsz(1)&"</a></dd>"&vbcrlf
strContent = strContent &"<dd><a href="""&rsz("curl")&""">"&cutstr(Replacehtml(rsz("Art_Intro")),50)&"</a></dd>"&vbcrlf
strContent = strContent &"</dl>"&vbcrlf
strContent = strContent &"<div class=""clear""></div>"&vbcrlf
strContent = strContent &"</div>"&vbcrlf
rsz.movenext

ni = ni + 1
If rsz.eof then exit do
loop


tpl.newKey "WebUrl",WebConfig("WebUrl",1)
tpl.newKey "WebUrl1",WebConfig("WebUrl",2)
tpl.newKey "WebUrl2",WebConfig("WebUrl",3)
tpl.newKey "WebTitle",T_TYPE2
tpl.newKey "keywords",WebConfig("WebKeyWords",Topic+1)
tpl.newKey "pro_class_lb",ProductsClass("lb")
tpl.newKey "pro_class_pp",ProductsClass("pp")
tpl.newKey "description",WebConfig("Description",Topic+1)
tpl.newKey "footer",WebConfig("footer",1)
tpl.newKey "fpage",showpage2(rsz,ii,"list")
tpl.newKey "str_content",strContent



if ii = 1 then
pagename = "../News/Index.html"
else
pagename = "../News/list_"&ii&".html"
end if

tpl.out_file pagename,tpl.gettext()
strContent = ""
Response.Write("<hr><b>成功生成"&pagename&"</b>")

next 'ii
end if
rsz.close
set rsz=nothing
set tpl=nothing
...全文
91 点赞 收藏 4
写回复
4 条回复
切换为时间正序
当前发帖距今超过3年,不再开放新的回复
发表回复
diplodocus 2009-02-03
但是这样生成的页面分页之后,虽然能分成N页,但每个页面的内容都一样。。。

Set fso = Server.CreateObject("Scripting.FileSystemObject")
set f=fso.OpenTextFile(server.mappath("../templets/aa.html"))
Pencat=f.ReadAll
f.close
set f=nothing

set rsz=server.createobject("adodb.recordset")
objStr="select * from [article] order by ID desc"
rsz.open objStr,Conn,1,1
pagesizes = 3
if rsz.eof then
response.Write("no data")
else
rsz.pagesize = pagesizes
for i = 1 to rsz.pagecount
rsz.absolutepage=i
ii = 0
do while (ii<pagesizes)
'response.Write(rsz(0)&"-"&rsz(1)&"<br />")
str = str & rsz(0)&"-"&rsz(1)&"<br />"
rsz.movenext
ii=ii+1
if rsz.eof then exit do
loop
page = "当前第"&i&"页<br><br>"
Pencat=Replace(pencat,"{content}",str)
Pencat=Replace(pencat,"{page}",page)

Set fout = fso.CreateTextFile(Server.MapPath("../list_"&i&".html"))
fout.WriteLine Pencat

Response.write "成功生成"
Response.write "<a href=""../list_"&i&".html"" target=""_blank"">../list_"&i&".html</a>"
str=""
next
end if
rsz.close
set rsz=nothing
set conn=nothing

fout.close
set fso=nothing
回复
diplodocus 2009-02-03


Set fso = Server.CreateObject("Scripting.FileSystemObject")
set rsz=server.createobject("adodb.recordset")
objStr="select * from [article] order by ID desc"
rsz.open objStr,Conn,1,1
pagesizes = 3
if rsz.eof then
response.Write("no data")
else
rsz.pagesize = pagesizes
for i = 1 to rsz.pagecount
rsz.absolutepage=i
ii = 0
do while (ii<pagesizes)

str = str & rsz(0)&"-"&rsz(1)&"<br />"
rsz.movenext
ii=ii+1
if rsz.eof then exit do
loop
str = str & "当前第"&i&"页<br><br>"

'fso.CreateFolder(Server.MapPath(folder))
Set fout = fso.CreateTextFile(Server.MapPath("../list_"&i&".html"))
fout.WriteLine str

Response.write "成功生成"
Response.write "<a href=""../list_"&i&".html"" target=""_blank"">../list_"&i&".html</a>"
str=""
next
end if
rsz.close
set rsz=nothing
set conn=nothing

'response.Write( str)
fout.close
'fso.close
set fso=nothing

奇怪。。。这样生成的页面就很正常。。
回复
ChinaXtHuLang 2009-02-03
[Quote=引用 3 楼 dogfish 的回复:]
当然,Pencat里的{content}和{page}在第一个循环里早被替换掉了。


VBScript code Set fso = Server.CreateObject("Scripting.FileSystemObject")
set f=fso.OpenTextFile(server.mappath("../templets/aa.html"))
Pencat=f.ReadAll
f.close
set f=nothing
Pencat1= Pencat

set rsz=server.createobject("adodb.recordset")
objStr="select * from [article] order by ID d…
[/Quote]
正解。学习了。
回复
Dogfish 2009-02-03
当然,Pencat里的{content}和{page}在第一个循环里早被替换掉了。

    Set fso = Server.CreateObject("Scripting.FileSystemObject")
set f=fso.OpenTextFile(server.mappath("../templets/aa.html"))
Pencat=f.ReadAll
f.close
set f=nothing
Pencat1= Pencat

set rsz=server.createobject("adodb.recordset")
objStr="select * from [article] order by ID desc"
rsz.open objStr,Conn,1,1
pagesizes = 3
if rsz.eof then
response.Write("no data")
else
rsz.pagesize = pagesizes
for i = 1 to rsz.pagecount
Pencat = Pencat1
rsz.absolutepage=i
ii = 0
do while (ii<pagesizes)
'response.Write(rsz(0)&"-"&rsz(1)&"<br />")
str = str & rsz(0)&"-"&rsz(1)&"<br />"
rsz.movenext
ii=ii+1
if rsz.eof then exit do
loop
page = "当前第"&i&"页<br><br>"
Pencat=Replace(pencat,"{content}",str)
Pencat=Replace(pencat,"{page}",page)

Set fout = fso.CreateTextFile(Server.MapPath("../list_"&i&".html"))
fout.WriteLine Pencat

Response.write "成功生成"
Response.write "<a href=""../list_"&i&".html"" target=""_blank"">../list_"&i&".html</a>"
str=""
next
end if
rsz.close
set rsz=nothing
set conn=nothing

fout.close
set fso=nothing
回复
相关推荐
发帖
ASP
创建于2007-09-28

2.8w+

社区成员

ASP即Active Server Pages,是Microsoft公司开发的服务器端脚本环境。
申请成为版主
帖子事件
创建了帖子
2009-02-03 12:01
社区公告
暂无公告