1. 程式人生 > >ASP生成靜態htm頁面基本程式碼!

ASP生成靜態htm頁面基本程式碼!

以下虛線框內為mk.asp檔案的具體程式碼:
--------------------------------------------------------------------------------
<%
filename="test.htm"
if request("body")<>"" then
set fso = Server.CreateObject("Scripting.FileSystemObject")
set fout = fso.CreateTextFile(server.mappath(""&filename&""))
fout.write "標題(title):" & request.form("title") & "<br>"
fout.write "內容(body):" & request.form("body")
fout.close
set fout=nothing
set fso=nothing
end if
%>
<form name="form1" method="post" action="">
<input name="title" size=18><br>
  <textarea name="body"></textarea>
  <br>
  <br>
  <input type="submit" name="Submit" value="生成">
</form>

--------------------------------------------------------------------------------
然後在瀏覽器輸入mk.asp這個頁面,填寫完畢後,就會生成test.htm這個檔案,裡面的內容就是你剛才填寫的。