当前位置: 首页 > 图文教程 > 网络编程 > ASP > ASP不用模板直接简单生成HTML页面

ASP
ASP编程中15个非常有用的例子 (二)
ASP与JSP的比较(一)
ASP与JSP的比较(二)
ASP中五种连接数据库的方法
从ASP调用SQL中的图像
用排序串字段实现树状结构(例程:连接字串)
用排序串字段实现树状结构(例程:删除贴子)
用排序串字段实现树状结构(例程:回复表单)
用排序串字段实现树状结构(例程:显示贴子内容)
用排序串字段实现树状结构(例程:显示树)
用排序串字段实现树状结构(存储过程)
用排序串字段实现树状结构(库结构)
用排序串字段实现树状结构(原理)
remote script文档(转载自微软)(一)
remote script文档(转载自微软)(二)
remote script文档(转载自微软)(三)
remote script文档(转载自微软)(四)
remote script文档(转载自微软)(五)
remote script文档(转载自微软)(六)
remote script文档(转载自微软)(七)

ASP不用模板直接简单生成HTML页面


出处:互联网   整理: 软晨网(RuanChen.com)   发布: 2009-09-28   浏览: 227 ::
收藏到网摘: n/a

我这里提供一个简单的不用模板可以直接生成HTML静态页的方法.

如一个正常的index.asp动态页面,

新建一个文件 makeasp2html.asp

<form method="post" action=""> 
    <textarea name="asp2html" style="display:none"><!--#include file="index.asp"--></textarea> 
    <input type="submit" value="生成html页"/> 
</form> 

<% 
If request.Form("asp2html")<>"" then 
    filename="index.html" 

    set fso = Server.CreateObject("Scripting.FileSystemObject") 
    set fout = fso.CreateTextFile(server.mappath(""&filename&"")) 

    fout.write request.form("asp2html") 
    fout.close 

    set fout=nothing 
    set fso=nothing 

end if 
%>
 

这样index.html文件就生成了,连模板都用不着,只要服务器要支持FSO,将正常情况下使用的ASP文件读取到textarea里就可以了。