To convert a dynamic web page into a static web page in asp, you can use a template to generate it. Use FsoFile to generate a static web page based on the template. It is more suitable for the transformation of products and news! Specific code implementation:
1. Template file (html)
Copy the code code as follows:
<html xmlns=http://www.w3.org/1999/xhtml>
<head>
<meta http-equiv=Content-Type content=text/html; charset=gb2312 />
<title>{title} - News Center - Aiyaya Jewelry Franchise Chain</title>
<meta name=keywords content={metak},Aiyaya jewelry store,Aiyaya franchise store,Aiyaya,Aiyaya franchise,Aiyaya jewelry,Aiyaya jewelry store,Aiyaya franchise store,Aiyaya chain store,How to join Aiyaya />
<meta name=description content={metad}, (Hong Kong) Aiyaya Jewelry International Group Co., Ltd. is a company engaged in jewelry, daily necessities, cosmetics, stationery, toys, etc. It has two profit centers: processing plants and chain stores. Hong Kong Aiyaya Jewelry Company welcomes you to join the Aiyaya Jewelry chain store. />
<link href=/css/style_new.css rel=stylesheet type=text/css />
</head>
<body>
<div><span class=font_white></span></div>
<!-- start from top -->
<div><span class=font_white></span></div>
<!-- start from top -->
<div id=top>
<div class=left></div>
<div class=right>
<div class=topuser>
<form class=formbox action=login_click.asp method=post name=loginform id=loginform onSubmit=return checkform2()>
<div style=line-height: 22px;height: 22px;>Username:
<input name=uname type=text class=bot id=uname size=10 maxlength=10 /> Password:
<input name=pwd type=password class=bot id=pwd size=10 maxlength=18/><label></label>
<input type=submit name=Submit value=Login/> <INPUT onClick=Javascript:window.location='/reg.asp'; type=button value=Register name=Submit2></div>
</form>
</div>
<div class=bottomuser><a href=/index.asp>Homepage</a> | <a href=/info_qiyejianjie.asp>Company Profile</a> | <a href=/class/>Product Display</a > | <a href=/news_xinwenzhongxin.asp>News Center</a> | <a href=/info_jiamengzhengce.asp>Distribution Policy</a> | <a href=/info_kaiyedali.asp>Opening Ceremony</a> | <a href=/info_zhuangxiufangan.asp>Decoration Plan</a> | <a href=/info_xingxiangzhanshi.asp>Image Display</a> | <a href= /info_jiamengliucheng.asp>Cooperation Process</a> | <a href=/info_touziwenda.asp>Investment Questions and Answers</a> | <a href=/zaixianliuyan.asp>Online message</a></div>
</div>
</div>
<!--End of top-->
<!--ad start-->
<div id=subject01><a href=/info_jiamengzhengce.asp target=_blank><img src=/images/pic_948x160.jpg /><!-- end of ad-->
<div class=clear></div>
<!--End of top-->
<!--ad start-->
<!--End of ad-->
<div class=clear></div>
<!-- Content begins -->
<div id=main>
<!--Start from the left-->
<div class=left>
<div class=top style=background:url(/images/fenlei_12_07.jpg);></div>
<div class=middle>
<ul>
<script language=javascript src=../../class.js></script>
<li class=middle02></li>
<li class=middle03>Free hotline: 4006-888048<br>
<strong>Mainland Headquarters:</strong><br>
Switchboard: 0579-89960888 <br />
Fax: 0579-85210995 <br>
<strong>Hong Kong Headquarters:</strong><br>
Tel: 00852-36458129 <br>
Fax: 00852-36458092 </li>
<li class=middle04></li>
</ul>
</div>
<div class=bottom></div>
<div class=leftnews></div>
</div>
<!--End on the left-->
<div class=right>
<div class=righttop></div>
<div class=rightmiddle>
<ul>
<li class=04><table width=700 border=0 cellpadding=0 cellspacing=0 background=/images/title.jpg>
<tr>
<td width=104 height=32 align=center><h1 style=color:#FFFFFF; font-size:14px; font-weight:bold; margin:0 auto; padding:0px; >News Center</h1>< /td>
<td width=596 align=right>Current location: <a href=/index.asp>Homepage</a> - News Center</td>
</tr>
</table>
<li class=02>
<h1 style=margin:10px; padding:2px; font-size:18px; text-align:center;>{title}</h1>
</li>
<li class=02 style=text-align:left;>{demo}</li>
</li>
</ul>
</div>
<div class=rightbottom></div>
</div>
</div>
<!--End of content-->
<div class=clear></div>
<meta http-equiv=Content-Type content=text/html; charset=gb2312 />
<link href=/css/style_new.css rel=stylesheet type=text/css />
<div class=clear></div>
<!--footer starts-->
<table cellspacing=0 cellpadding=0 width=948 align=center border=0>
<tbody>
<tr>
<td valign=center align=middle width=79><a href=/info_lianxiwomen.asp><img height=66 /><td width=869><span class=font_space01><a href=/info_qiyejianjie.asp>About Love Yeah Yeah</a> │ <a href=/info_jiamengzhengce.asp>Franchise Policy</a> | <a href=/info_zhuangxiufangan.asp>Decoration Plan</a> | <a href=/info_jiamengyoushi.asp>Join Advantages</a> | <a href=/class/>Product Display</a>│<a href=/ zaixianliuyan.asp>Leave a message online</a>│<a href=/info_lianxiwomen.asp>Contact us</a>│<a href=sitemap.html target=_blank>Sitemap</a></span><br />
Mainland Area Address: Building 8, No. 123, Shiyu Road, Economic Development Zone, Yiwu City, Zhejiang Province (next to Choujiang Middle School) Mainland Area Tel: 0579-89960888 Toll-free hotline: 4006-888048 <br />
</td>
</tr>
</tbody>
</table>
<!--End of footer-->
<span style=visibility: hidden;><a href=http://www.51aiyaya.com target=_blank><strong>Oops</strong></a>
<a href=http://www.51aiyaya.com target=_blank>Aiyaya Join</a>
<a href=http://www.51aiyaya.com target=_blank>Aiyaya jewelry</a> <script src=http://s23.cnzz.com/stat.php?id=1117055&web_id=1117055 language=JavaScript charset=gb2312></script></span>
</body>
</html>
2. Processed files (asp)
Copy the code code as follows:
<!--#include file=conn.asp-->
<%Server.ScriptTimeOut=99999999%>
<%
dim action,id,news
Layout=news
id=request.QueryString(id)
action=request.QueryString(action)
select case action
case add
%>
<%
'Generate all html
case htmlall
set rs=server.CreateObject(adodb.recordset)
Sql = Select id from news order by id
rs.open sql,conn,1,1
do while not rs.eof
FsoFile news,rs(id)
response.write<div style='color:#003333;' align='center'>&rs(id)&News generated HTML successfully!</div>
rs.movenext
loop
rs.close
response.write<div style='color:#FF0000;' align='center'>All news generated HTML successfully!</div></br>
end select
%>
<%
'Generate Chinese html
Function FsoFile(Layout,ID)
Dim Fso,FilePath,FsoF,FsoH,FsoRs,CreateFilePath
FSOCreateDIR ../news/ & ID &
CreateFilePath = ../news/ & ID & 'HTML folder
FilePath=Server.Mappath(CreateFilePath) & /index.html 'Define the generated html file name
Set Fso=Server.CreateObject(Scripting.FileSystemObject)
Set FsoH=Fso.OpenTextFile(Server.Mappath(../templates/news_show.html),1,true) 'Read template
Content = FsoH.ReadAll
Set FsoRs = Conn.Execute(select * from news where id=&id)
title=FsoRs(title)
demo=FsoRs(demo)
Content = Replace(Content,{id},FsoRs(id))
Content = Replace(Content,{title},FsoRs(title))
Content = Replace(Content,{demo},FsoRs(demo))
Content = Replace(Content,{webname},webname)
Content = Replace(Content,{icp},icp)
Content = Replace(Content,{dianhua},dianhua)
Content = Replace(Content,{dizhi},dizhi)
Content = Replace(Content,{qq},qq)
Content = Replace(Content,{alibaba},alibaba)
Content = Replace(Content,{tongji},tongji)
FsoRs.Close
Set FsoRs=Nothing
set stm = server.createobject(ADODB.Stream)
stm.Charset = gb2312 'Define encoding
stm.Open
stm.WriteText content
stm.SaveToFile FilePath, 2
set stm = nothing
End Function
%>
<%
function FSOCreateDIR(LocalPath)
dim patharr,path_level,i,pathtmp,cpath,CreateDIR,FileObject
on error resume next
LocalPath = Server.MapPath(LocalPath)
LocalPath = replace(LocalPath,/,/)
set FileObject = server.createobject(Scripting.FileSystemObject)
patharr = split(LocalPath,/)
path_level = ubound(patharr)
for i = 0 to path_level
if i=0 then pathtmp = patharr(0) & / else pathtmp = pathtmp & patharr(i) & /
cpath = left(pathtmp,len(pathtmp)-1)
if not FileObject.FolderExists(cpath) then FileObject.CreateFolder(cpath)
next
set FileObject = nothing
if err.number<>0 then
CreateDIR = false
err.Clear
else
CreateDIR = true
end if
end function
%>
3. Add and generate static news links in the background
Copy the code code as follows:
<TD height=20 align=center><a href=../admin_product/saveaddnews.asp?action=htmlall target=ggdlab>Generate news static</a></TD>