如何用ASP输出HTML文件?

时间:2010-06-11 20:01:00 

如何用ASP输出HTML文件?

<!--#include file="top.inc"-->
<%
u_title=request.form("u_title")
' 检查标题是否被输入
if u_title = "" then
%>
<form method="POST" action="<%= request.servervariables("script_name") %>">
 <!--当没有标题输入时显示输入框-->
  <p>文件标题<br>
  <input type="text" name="u_title" size="35"></p>
  <p>Font Size<br>
  <select size="1" name="u_text_size">
  <option selected value="1">1</option>
  <option value="2">2</option>
  <option value="3">3</option>
  <option value="4">4</option>
  <option value="5">5</option>
  <option value="6">6</option>
  &nbsp;
  </select></p>
  <p>第1段<br>
  <textarea rows="2" name="u_paragraph1" cols="35"></textarea></p>
  <p>第2段<br>
  <textarea rows="2" name="u_paragraph2" cols="35"></textarea><input type="submit" value="提交" ></p>
</form>
<%
end if
%>
<%
if u_title <> "" then
    u_title=request.form("u_title")
    u_paragraph1=request.form("u_paragraph1")
    u_paragraph2=request.form("u_paragraph2")
    u_text_color=request.form("u_text_color")
    u_text_size=request.form("u_text_size")
    g_filename=replace(u_title," ","_")
' 如果有一个用户输入了标题,则获取所有的用户输入的内容
set fso = createobject("scripting.filesystemobject")
Set act = fso.CreateTextFile(server.mappath("write2htm/"&g_filename & "-"& month(date())& day(date())& year(date()) &".htm"), true)
'  创建create the text (html) file文件到服务器,并添加mmddyyyy 格式年月日
' 写所有用户输入的text (html) 文件, .htm 扩展名文件可以很容易地转换成你网站最需要的.asp 或 .inc文件
    act.WriteLine "<html>"
    act.WriteLine chr(13) 
    act.WriteLine "<title>"& u_title &"</title>"
    act.WriteLine chr(13)
    act.WriteLine "<body bgcolor='#FFFFFF'>"
    act.WriteLine chr(13)
    act.WriteLine "<p align='center'><font face='arial' size='"& u_text_size &"'>"
    act.WriteLine chr(13)
    act.WriteLine  u_title &"</p>"
    act.WriteLine chr(13)
    act.WriteLine "<p align='left'><font face='arial' size='"&u_text_size&"'>"
    act.WriteLine chr(13)
    act.WriteLine  u_paragraph1 &"</p>"
    act.WriteLine chr(13)
    act.WriteLine "<p align='left'><font face='arial' size='"& u_text_size &"'>"
    act.WriteLine chr(13)
    act.WriteLine u_paragraph2 &"</p>"
    act.WriteLine chr(13)
    act.WriteLine "<p>&nbsp;</p><p>&nbsp;</p><p>&nbsp;</p>"
    act.WriteLine "<p align='center'><font face='arial' size='"& u_text_size &"'>"
    act.WriteLine "此文件被创建!"
    act.WriteLine  now() &"</p>"
act.Close
' 关闭文件
%>
您的页面已成功创建!请点击查看. 
<a href="write2htm/<%= g_filename &"-"& month(date())& day(date())& year(date())  %>.htm" 
target="_blank">查看</a>
<br>
<br>
<% response.write "<html>"
    response.write chr(13) 
    response.write "<title>"& u_title &"</title>"
    response.write chr(13)
    response.write "<body bgcolor='#FFFFFF'>"
    response.write chr(13)
    response.write "<p align='center'><font face='arial' size='"& u_text_size &"'>"
    response.write chr(13)
    response.write  u_title &"</p>"
    response.write chr(13)
    response.write "<p align='left'><font face='arial' size='"&u_text_size&"'>"
    response.write chr(13)
    response.write  u_paragraph1 &"</p>"
    response.write chr(13)
    response.write "<p align='left'><font face='arial' size='"& u_text_size &"'>"
    response.write chr(13)
    response.write u_paragraph2 &"</p>"
    response.write chr(13)
    response.write "<p>&nbsp;</p><p>&nbsp;</p><p>&nbsp;</p>"
    response.write "<p align='center'><font face='arial' size='"& u_text_size &"'>"
    response.write "此文件被创建!"
    response.write  now() &"</p>"
end if
%>
<!--#include file="bottom.inc"-->

标签:html,asp
0
投稿

猜你喜欢

  • python中迭代器(iterator)用法实例分析

    2023-12-16 05:32:51
  • Dreamweaver MX 2004新特点

    2008-02-03 11:35:00
  • Python对图片进行resize、裁剪、旋转、翻转问题

    2023-03-01 11:07:05
  • python模块常用用法实例详解

    2023-07-30 01:38:54
  • PHP读MYSQL中文乱码的解决方法

    2024-05-11 09:18:58
  • tensorflow 恢复指定层与不同层指定不同学习率的方法

    2023-08-27 23:09:14
  • pandas loc与iloc用法及区别

    2023-01-22 08:26:53
  • 百度首席设计师 用户体验部总监郭宇演讲

    2008-09-03 12:41:00
  • GO语言常用的文件读取方式

    2024-05-21 10:21:30
  • python networkx 包绘制复杂网络关系图的实现

    2021-03-27 06:11:39
  • python实现的web监控系统

    2022-01-28 20:31:57
  • 一个asp版XMLDOM操作类

    2011-04-19 10:50:00
  • Python爬虫突破反爬虫机制知识点总结

    2021-09-17 12:38:22
  • 如何设置SQL Server数据库全文索引服务

    2009-01-13 13:46:00
  • golang中defer的关键特性示例详解

    2023-08-06 06:12:45
  • MySql完整卸载的四个步骤详解

    2024-01-18 00:30:52
  • Python爬虫之获取心知天气API实时天气数据并弹窗提醒

    2023-04-17 14:40:58
  • javascript+HTML5 canvas绘制时钟功能示例

    2024-05-05 09:14:01
  • MySQL主从复制之半同步semi-sync replication

    2024-01-20 09:48:16
  • python生成图片验证码的方法

    2022-07-27 13:39:11
  • asp之家 网络编程 m.aspxhome.com