asp 生成静态问题

jinx151 2008-04-30 11:19:45
看到过生成的静态的方法:
模板跟replace 进行替换.用FSO进行生成.
简单的,例如新闻标题,内容,时间等直接替换即可.
但复杂点(比如代码有循环,asp代码不断穿插),确有不知如何进行处理:
---------------------------------------------

<table width="95%" border="0" cellpadding="0" cellspacing="1" bgcolor="#CCCCCC">
<tr bgcolor="#FFFFFF">
<td width="25%" rowspan="2" align="center">手机型号</td>
<td height="20" colspan="3" align="center" bgcolor="#efeded"><strong>对应电池型号</strong></td>
</tr>
<tr bgcolor="#FFFFFF">
<td width="25%" height="25" align="center">
<%if name1="商务版手机电池" then
response.write("<font color=#44ae8a><b>商务版手机电池</b></font>")
else
response.write("商务版手机电池")
end if %></td>
<td width="26%" align="center">
<%if name1="商业版手机电池" then
response.write("<font color=#44ae8a><b>商业版手机电池</b></font>")
else
response.write("商业版手机电池")
end if %> </td>
<td width="24%" align="center">
<%if name1="普及版手机电池" then
response.write("<font color=#44ae8a><b>普及版手机电池</b></font>")
else
response.write("普及版手机电池")
end if %></td>
</tr>
<%xhsql="select sjxhname from sjxh where smallclassname='"&name3&"' and bigclassname='"&name1&"' order by id desc"
set xhrs=server.createObject("adodb.recordset")
xhrs.open xhsql,conn,1,1
while not xhrs.eof
chsql="select articleid,title from product where smallclassname='"&name3&"' and bigclassname='"&name1&"' and sjxhname like '%"&xhrs("sjxhname")&"%' and passed=1 order by articleid"
set chrs=server.createObject("adodb.recordset")
chrs.open chsql,conn,1,1
if not chrs.eof then
%>
<tr bgcolor="#FFFFFF">
<td height="25" align="center"><%=xhrs("sjxhname")%></td>
<td align="center"><%
while not chrs.eof
chtitle=chrs("title")
response.write("<a href=prdinfo.asp?name="&name&"&name1="&name1&"&name3="&name3&"&name4="&chtitle&"&id="&chrs("articleid")&" class=zt><font color=#ff6633>"&chtitle&"</font></a><br>")
chrs.movenext
wend%></td>
<td align="center"><%sysql="select articleid,title from product where smallclassname='"&name3&"' and bigclassname='商业版手机电池' and sjxhname like '%"&xhrs("sjxhname")&"%' and passed=1 order by articleid"
set syrs=conn.execute(sysql)
while not syrs.eof
sytitle=syrs("title")
response.write("<a href=prdinfo.asp?name="&name&"&name1="&name1&"&name3="&name3&"&name4="&sytitle&"&id="&syrs("articleid")&" class=zt><font color=#3399ff>"&sytitle&"</font></a><br>")
syrs.movenext
wend
syrs.close
set syrs=nothing
%></td>
<td align="center"><%sysql="select articleid,title from product where smallclassname='"&name3&"' and bigclassname='普及版手机电池' and sjxhname like '%"&xhrs("sjxhname")&"%' and passed=1 order by articleid"
set syrs=conn.execute(sysql)
while not syrs.eof
sy2title=syrs("title")
response.write("<a href=prdinfo.asp?name4="&sy2title&"&id="&syrs("articleid")&" class=zt><font color=#ff6633>"&sy2title&"</font></a><br>")
syrs.movenext
wend
syrs.close
set syrs=nothing
%></td>
</tr>
<%end if
chrs.close
set chrs=nothing
xhrs.movenext
wend
xhrs.close
xhrs=nothing%>
</table>
...全文
93 4 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
md5e 2008-04-30
  • 打赏
  • 举报
回复
用一个变量

str="<table..."
do wile...
str=str & "<a href=...>" + rs("title") + "</a>"
...

loop
...

okfile = replace(okfile,"#titlename#",webtitle)





'############热点############
hot=""
set rs_u=server.createobject("adodb.recordset")
sql_u="select title,url from happywz_URL where space=6 order by id"
rs_u.open sql_u,conn,1,1
while not rs_u.eof
hot=hot+"<a href='"&rs_u("url")&"' target='_blank' class=""STYLE3"">"&rs_u("title")&"</a> "
rs_u.movenext
wend
rs_u.close
'#########End热点#########

....
'#############在线杀毒########
sql="Select Top 6 wwwurl,wwwweb From happywz_WEB Where wwwsort='在线杀毒' order by isok ,addtime desc,wwwid"
set rs=Conn.Execute(sql)
i=1
Kill="<UL>"
do while not rs.eof
Kill=Kill &"<LI><a href='"&rs("wwwurl")&"' target='_blank'>"&rs("wwwweb")&"</a></LI>"
if i mod 2=0 then Kill=Kill & "</UL><UL>"
i=i + 1
rs.movenext()
Loop
Kill=Kill & "</UL>"
'###########End在线杀毒##########
set rs_u=nothing
hot2=""
set rs_u=server.createobject("adodb.recordset")
sql_u="select title,url from happywz_URL where space=7 order by id"
rs_u.open sql_u,conn,1,1
while not rs_u.eof
hot2=hot2+"<li><a href='"&rs_u("url")&"' target='_blank'>"&rs_u("title")&"</a> </li>"
rs_u.movenext
wend
rs_u.close
set rs_u=nothing
fz=""
set rs_u=server.createobject("adodb.recordset")
sql_u="select title,url from happywz_URL where space=4 order by id"
rs_u.open sql_u,conn,1,1
while not rs_u.eof
fz=fz+"<LI><a href='"&rs_u("url")&"' target='_blank'>"&rs_u("title")&"</a> </LI>"
rs_u.movenext
wend
rs_u.close
set rs_u=nothing
news=""
set rs_url=server.createobject("adodb.recordset")
sql_url="select top 16 wwwid,wwwurl,wwwweb,addtime,isok,hits from happywz_WEB order by wwwid desc"
rs_url.open sql_url,conn,1,1
while not rs_url.eof
news=news&"<LI><A HREF='"&rs_url("wwwurl")&"' TARGET=_blank>"&left(rs_url("wwwweb"),6)&"</A>"&jian&"</LI>"
rs_url.movenext
wend
rs_url.close
set rs_url=nothing
indexhtm=""
set rs_u=server.createobject("adodb.recordset")
sql_u="select sort,sml from happywz_SORT where sortstep=0"
rs_u.open sql_u,conn,1,1
jishu=1
while not rs_u.eof
if jishu/8 mod 2=0 and jishu mod 8 =1 then
indexhtm=indexhtm+"<UL class=bg0>"
elseif jishu mod 8=1 then
indexhtm=indexhtm+"<UL class=bg1>"
end if
indexhtm=indexhtm+"<LI><a href='html/"&rs_u("sml")&".htm'>"&rs_u("sort")&"</a> </LI>"
if jishu mod 8 = 0 then
indexhtm=indexhtm+"</UL>"
end if
jishu=jishu+1
rs_u.movenext
wend
rs_u.close
set rs_u=nothing
service=""
set rs_u=server.createobject("adodb.recordset")
sql_u="select * from happywz_SERVICE where index=0 order by id Desc"
rs_u.open sql_u,conn,1,1
jishu=1
while not rs_u.eof
if jishu mod 4 =1 then
service=service+"<UL class=bg0>"
elseif jishu=1 or jishu mod 2 = 1 then
service=service+"<UL class=bg1>"
end if
service=service+"<LI><a href='service/"&rs_u("id")&".htm'>"&rs_u("name")&"</a> </LI>"
if jishu mod 2 = 0 then
service=service+"</UL>"
end if
jishu=jishu+1
rs_u.movenext
wend
rs_u.close
set rs_u=nothing
'读出模版文件
set rs_2 = server.CreateObject ("Adodb.recordset")
if webv>0 then
sql_2="select * from happywz_DEMO where ifuse=1 and demoid="&webv
else
errmsg=errmsg+"<br>"+"<li>首页模版未绑定或模版丢失,请重新绑定!!</a>!"
call diserror()
response.end
end if
rs_2.open sql_2,conn,1,1
okfile=rs_2("demohtml")
rs_2.close
set rs_2=nothing

'---------替换模板数据
okfile = replace(okfile,"#titlename#",webtitle)
okfile = replace(okfile,"#url#",weburl)
okfile = replace(okfile,"#name#",webname)
okfile = replace(okfile,"#email#",webemail)
okfile = replace(okfile,"#webstat#",webstat)
okfile = replace(okfile,"#memo#",webdescription)
okfile = replace(okfile,"#indexhtm#",indexhtm)
okfile = replace(okfile,"#logo2#",weblogo2)
okfile = replace(okfile,"#keywords#",webkeywords)
okfile = replace(okfile,"#menu#",menu)
okfile = replace(okfile,"#hot#",hot)
okfile = replace(okfile,"#hot2#",hot2)
okfile = replace(okfile,"#fz#",fz)
okfile = replace(okfile,"#service#",service)
okfile = replace(okfile,"#gao#",webgao)
okfile = replace(okfile,"#new#",news)
okfile = replace(okfile,"#Breadcrumbs#",Breadcrumbs)'友情链接
okfile = replace(okfile,"#Usually_1#",Usually_1)'实用工具
okfile = replace(okfile,"#Usually_2#",Usually_2)'实用工具
okfile = replace(okfile,"#Usually_3#",Usually_3)'实用工具
okfile = replace(okfile,"#Usually_4#",Usually_4)'实用工具
okfile = replace(okfile,"#Usually_5#",Usually_5)'实用工具
okfile = replace(okfile,"#HotSearch#",HotSearch)'热点查询
okfile = replace(okfile,"#HotSearchMore#",HotSearchMore)'热点查询更多
okfile = replace(okfile,"#Transportation#",Transportation)'交通旅游
okfile = replace(okfile,"#Finance#",Finance)'金融理财
okfile = replace(okfile,"#Health#",Health)'健康查询
okfile = replace(okfile,"#Study#",Study)'学习应用
okfile = replace(okfile,"#Business#",Business)'商业经济
okfile = replace(okfile,"#Everyday#",Everyday)'日常查询
okfile = replace(okfile,"#Kill#",Kill)'在线杀毒
Set fso = Server.CreateObject(""&fsoset&"")
Set fout = fso.Createtextfile(server.mappath("../index.html"),true)
fout.writeline okfile
fout.close
%>
<td><div align="center"><font color="#0000FF">首页更新完成</font> 地址为默认 <a href="../index.html" target="_blank">../index.html </a></div></td>
</tr><%end if%>
</table>
<TABLE WIDTH="99%" BORDER="0" CELLPADDING="2" CELLSPACING="1" BGCOLOR="#0099CF" align="center">
<TR BGCOLOR="#0099CF"> <TD HEIGHT="22"
COLSPAN="2" align='center'><span class="STYLE2">操作说明</span></TD>
</TR> <TR BGCOLOR="#ffffff"> <TD WIDTH="87" HEIGHT="30"><B>操作说明:</B></TD><TD
HEIGHT="30">
<LI>您只需点击更新首页按钮就可按照你的设定更新首页</TD></TR> </TABLE>

</body>
</html>

银狐被占用 2008-04-30
  • 打赏
  • 举报
回复
表格用程序来输出。
windwl 2008-04-30
  • 打赏
  • 举报
回复
没有
jinx151 2008-04-30
  • 打赏
  • 举报
回复
把其他的代码用程序输出
这种方法可行,但是,这样输出往往很是麻烦.
想问下有没其他方法生成静态
后台管理,网址后加admin/Wrzcnet_login.asp帐户:admin密码:admin   仿京东商城网上购物系统正式版源码下载商城网站模板V2030强势推出!国内首个完全仿京东商城的购物系统,无论是程序的功能,还是网站系统的网站模板都是很京东商城风格的.中国最好的购物系统,本商城购物系统采用先进的AJAX技术与XML技术相融生成静态,速度更快!管理也更为轻松!仿京东商城源码,仿京东商城源码下载,仿京东商城系统源码,免费京东商城源代码,软件代码多重过滤结合强大的SEO优化可以快速被搜索引擎收录,独特的静态生成算法可以大大减轻服务器的负担,无论在生成速度还是安全方面都达到国内领先水平。   仿京东商城系统,京东商城程序, 仿京东商城模板V2030的部分特点与精华:在拥有HTM静态生成功能的基础上,系统在SEO优化方面更是表现得淋漓尽致,软件代码多重优化过滤,无论是整站还是商品、三级分类的各个设置等细节方面,均可独立设置搜索关键词及描述,让您的客户第一时间在搜索引擎中找到你!   由此可见,HTML静态版系统具有诸多优点:1、第一时间被搜索引擎收录,让客户第一时间找到您!2、大大减轻服务器负担,同等环境下,HTML静态版浏览速度要比ASP高出近10倍!即使在服务器负载较重的情况下,也不会让您漏失客户!3、更安全!HTML静态文件无任何漏洞,让您高枕无忧。4、更易维护和管理,后台只须轻轻一点,即可全部生成,方便快捷5、是电子商务时代所趋,目前较为流行的购物站均采用静态化的HTML,采用HTML静态版已是大势所趋。   免费的生成html静态文件的仿京东商城程序,多风格的网店系统,国内最强大的32套模板购物网站网软志成HTML静态版V2030,采用更为直观的静态生成模式!所有静态生成均在一个页面完成。购物网站模板下载,免费的购物程序商业版,同时采用极为先进的进度条调度模式!系统生成静态统一采用百分比及进度条直观显示,全站静态生成以进度条显示,以及生成的百度比!非常形象。生成过程随时掌控,使之更直观的呈现在人们面前!同时运用先进的技术手段,采用静态生成与动态跟踪技术,网店网站模板,网上商城网页模板下载,完全版的电子商务网站系统,静态生成页面实时显示未生成的数据,独创不重复生成技术!运用多种不同的生成规则使生成速度变的更为快速,仿京东商城网上购物系统正式版源码下载商城网站模板在生成HTM的基础上实现多种只有动态文件才有的功能,如用户状态、新闻的浏览率、相应的价格级别等信息!完美解决了HTM文件不能实时显示动态信息的瓶颈。   京东商城源程序免费下载,仿京东商城模板下载,京东商城购物网站程序,下载京东商城模板,以人性化管理为出发点,系统加入多种智能静态生成生成HTML的购物网站网页模板,商城系统完全版,网上商店开店系统,管理商城也由此变得游刃有余!有仿京东商城购物系统access版,仿京东商城网站模板mssql版,仿京东商城网站管理系统access生成html版,京东商城风格网页模板网店系统mssql生成html版下载.   系统功能方面更是十分强大!静态版率先支持了商品三级分类,支持七种在线支付,京东商城网源代码,京东商城网站源程序,京东商城源码,仿京东商城免费模板,同时支持Excel批量导入商品、文字或图片水印设置功能、商品优惠券及免运费设置的高级功能于一体,同时支持邮件订单通知与群发、完美整合BBS程序以及图片自动清除功能等等。

28,409

社区成员

发帖
与我相关
我的任务
社区描述
ASP即Active Server Pages,是Microsoft公司开发的服务器端脚本环境。
社区管理员
  • ASP
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧