pencat=rs.Fields.Item("m_content").Value
pencat=replace(pencat,"t_title",n_title)
pencat=replace(pencat,"t_author",n_author)
pencat=replace(pencat,"t_content",n_content)
Set fso = Server.CreateObject("Scripting.FileSystemObject")
Set fout = fso.CreateTextFile(server.mappath(fpath&"\" &fname))
fout.WriteLine pencat
fout.close
2、如下给出要生成的网页模板:
<html>
<head>
<meta http-equiv=""Content-Language"" content=""zh-cn"">
<meta http-equiv=""Content-Type"" content=""text/htmlcharset=gb2312"">
<meta name=""GENERATOR"" content=""Microsoft FrontPage 4.0"">
<meta name=""ProgId"" content=""FrontPage.Editor.Document"">
<title></title>
</head>
<body topmargin=""0"" leftmargin=""0"">
<table border=""0"" width=""760"" height=""100%"" background=""background.jpg"" >
<tr>
<td width=""752"" height=""10"" colspan=""3"">
<p align=""center"">t_title
</td>
</tr>
<tr>
<td width=""752"" height=""18"" colspan=""3"">
<div align=""center"">
</div>
<div align=""center"">
<font size=""2"">
作者:</font><font color=""#990000"">t_author</font>
<font size=""2"">
加入时间:</font><font color=""#990000"">t_date</font>
</div>
</td>
</tr>
<tr>
<td width=""15%"" height=""100%"" valign=""top"">
</td>
<td width=""70%"" height=""100%"" valign=""top"">
t_content
</td>
<td width=""15%"" height=""100%"" valign=""top"">
</td>
</tr>
</table>
</body>
</html>
3、解释
(1)pencat=rs.Fields.Item("m_content").Value
pencat为一个字符串变量。
rs.Fields.Item("m_content").Value就是如上2、网页模板的全部HTML字符
(2)pencat=replace(pencat,"t_title",n_title)
pencat=replace(pencat,"t_author",n_author)
pencat=replace(pencat,"t_content",n_content)
以上三句就是将字符串中的字串替换成为你所需要的内容,即ASP中动态获得的内容。
(3)Set fso = Server.CreateObject("Scripting.FileSystemObject")
Set fout = fso.CreateTextFile(server.mappath(fpath&"\" &fname))
fout.WriteLine pencat
fout.close
以上为将刚刚组合所得的网页代码写入文件的过程。第一句定义fso文件,第二句创建输出流文件,其中fpath为你想要存储的文件的路径,fname为文件名;后两句是将字符串写入文件和关闭输出流文件。
HTML个人简历代码如下<html>
<head>
<title>真实名字</title>
<mate name="keywords" content="个人简历"/>
<mate name="description" content="XXXX的个人简历"/>
</head>
<body>
<table border=5 bordercolor=red align=center>
<tr height=70 bgcolor=green align='center'>
<td width=720 colspan=6 align=center
><font size=5 ><b><a href=http://blog.sina.com.cn/u/3083814572>个人简历
</a></b></font></td>
</tr>
<tr height=50 bgcolor=green>
<td width=110 align=center
><font size=5>姓名:</td>
<td width=150 align=center
><font size=5><a
href=http://user.qzone.qq.com/504660181/infocenter#home>XXX</td>
<td width=110 align=center
><font size=5>性别:</td>
<td width=150 align=center
><font size=5>男</td>
<td width=200 colspan=2 rowspan=4><img
src="http://b264.photo.store.qq.com/psb?/1e607185-b189-4edb-a6a9-
3c3e3f4bc25a/lpJL3i5H3AWovj6*eYZTbXKgOtEQuAkqByv4H*wMyRw!/b/dKMBZp1AIgAA
&bo=gALgAQAAAAABAEQ" alt="XXX照片" width=200 height=200></td>
</tr>
<tr height=50 bgcolor=green>
<td width=110 align=center
><font size=4 align=center
>出生年月:</td>
<td width=150 align=center
><font size=5>1992.4.6</td>
<td width=110 align=center
><font size=5>民族:</td>
<td width=150 align=center
><font size=5>汉</td>
</tr>
<tr height=50 bgcolor=green>
<td width=110 align=center
><font size=5>学历:</td>
<td width=150 align=center
><font size=5 align=center
>大专</td>
<td width=110 align=center
><font size=5>专业:</td>
<td width=150 align=center
><font size=4>数控车工</td>
</tr>
<tr height=50 bgcolor=green>
<td width=110 align=center
><font size=5>籍贯:</td>
<td width=150 align=center
><font size=4>河南原阳</td>
<td width=110 align=center
><font size=4>联系电话:</td>
<td width=150 align=center
><font size=3>13602664383</td>
</tr>
<tr height=50 bgcolor=green>
<td width=100 align=center
><font size=4>毕业学校:</td>
<td width=620 colspan=5 align=center
><font size=5>河南经济贸易高级技工学校</td>
</tr>
<tr height=50 bgcolor=green>
<td width=110 align=center
><font size=5>住址:</td>
<td width=610 colspan=5 align=center
><font size=5>下油松新村</td>
</tr>
<tr height=50 bgcolor=green>
<td width=110 align=center
><font size=4>电子邮箱:</td>
<td width=610 colspan=5 align=center
><font size=5>hiyangson@163.com</td>
</tr>
<tr height=50 bgcolor=green>
<td width=720 colspan=6 align=center
><font size=5>教育历程</td>
</tr>
<tr height=50 bgcolor=green>
<td width=720 colspan=6 align=center>2007.9-2011.6 在河南高级技工学校读
中专</td>
</tr>
<tr height=50 bgcolor=green>
<td width=720 colspan=6 align=center>2010.9-至今 报读郑州轻工业学院成人大
专</td>
</tr>
<tr height=50 bgcolor=green>
<td width=720 colspan=6 align=center
><font size=5>工作经历</td>
</tr>
<tr height=50 bgcolor=green>
<td width=720 colspan=6 align=center>2011.6-至今 在富士康科技集团工作
</td>
</tr>
<tr height=50 bgcolor=green>
<td width=720 colspan=6 align=center
><font size=5>自我评价</td>
</tr>
<tr height=50 bgcolor=green>
<td width=720 colspan=6>个人工作勤奋,认真负责,能吃苦耐劳,尽职尽责,
</td>
</tr>
<tr height=50 bgcolor=green>
<td width=720 colspan=6></td>
</tr>
</table>
<center><script language="javascript" type="text/javascript"
src="http://js.users.51.la/15653809.js"></script>
<noscript><a href="http://www.51.la/?15653809" target="_blank"><img
alt="我要啦免费统计"
src="http://img.users.51.la/15653809.asp" style="border:none"
/></a></noscript>
</body>
</html>
看下这里:http://www.tc-21.com/Photo/Case/EduResTraSite/Index.html
是经典案例,但也可以直接套用的,希望对你有所帮助!