ASP网站制作之怎样利用ASP天生HTML文件
ASP一般认为只能运行在IIS上,正如前面所提到的,这并不是十分正确,事实上,ASP也能运行在Apache上。ApacheASP可在任意Apache服务器上运行有限的ASP功能,所需做的,只需打开mod_perl。天生html 利用ASP天生HTML文件,共有两个页面index.htm是首页.程序对照复杂,次要是用了ASP里的文件操纵工具。<!--index.htm---------------------->
<html>
<head>
<title>UntitledDocument</title>
<metahttp-equiv="Content-Type"content="text/html;
charset=gb2312">
</head><body>
<tablewidth="770"border="0"align="center"cellpadding="0"cellspacing="0">
<tr>
<td><formname="form1"method="post"action="send.asp">
<tablewidth="100%"border="0"cellpadding="0"cellspacing="0"bgcolor="#CCFFFF">
<tr>
<tdheight="20"><divalign="center">发送动静</div></td>
</tr>
<tr>
<td><divalign="center">
<textareaname="msg"cols="100"rows="6"></textarea>
</div></td>
</tr>
<tr>
<td><divalign="center">
<inputtype="submit"name="Submit"value="Submit">
<inputtype="reset"name="Submit2"value="Reset">
</div></td>
</tr>
</table>
</form></td>
</tr>
</table>
</body>
</html>
//send.asp
<%
functionchan_time(shijian)转换日期工夫函数
s_year=year(shijian)
iflen(s_year)=2thens_year="20"&s_year
s_month=month(shijian)
ifs_month<10thens_month="0"&s_month
s_day=day(shijian)
ifs_day<10thens_day="0"&s_day
s_hour=hour(shijian)
ifs_hour<10thens_hour="0"&s_hour
s_minute=minute(shijian)
ifs_minute<10thens_minute="0"&s_minute
chan_time=s_year&s_month&s_day&s_hour&s_minute
endfunction
functionchan_data(shijian)转换日期工夫函数
s_year=year(shijian)
iflen(s_year)=2thens_year="20"&s_year
s_month=month(shijian)
ifs_month<10thens_month="0"&s_month
s_day=day(shijian)
ifs_day<10thens_day="0"&s_day
chan_data=s_year&s_month&s_day
endfunction
functionchan_file(shijian)转换日期工夫函数
s_month=month(shijian)
ifs_month<10thens_month="0"&s_month
s_day=day(shijian)
ifs_day<10thens_day="0"&s_day
s_hour=hour(shijian)
ifs_hour<10thens_hour="0"&s_hour
s_minute=minute(shijian)
ifs_minute<10thens_minute="0"&s_minute
s_ss=second(shijian)
ifs_ss<10thens_ss="0"&s_ss
chan_file=s_month&s_day&s_hour&s_minute&s_ss
endfunction
top="<html><head><title>news</title></head><body>"
botom="</body></html>"
msg=request.Form("msg")
msg=replace(msg,vbcrlf,"")
msg=replace(msg,chr(9),"")
msg=replace(msg,"","")
msg=replace(msg,"
","<br>")
msg=replace(msg,"
","<br>")
msg=top&msg&botom
Setfs=Server.CreateObject("Scripting.FileSystemObject")
all_tree2=server.mappath("news")&""&chan_data(now)
if(fs.FolderExists(all_tree2))then判别明天的文件夹是不是存在
else
fs.CreateFolder(all_tree2)
endif
pass=chan_file(now)
randomize利用体系计时器来初始化乱数发生器
pass=rnd(pass)
pass=get_pass(pass)
pass=left(pass,10)file1=pass
files=file1&".txt"
filez=all_tree2&""&files
setts=fs.createtextfile(filez,true)写文件
forz=1tolen(msg)
write_now=mid(msg,z,1)
ts.write(write_now)
next
ts.writeline(all_msg)
ts.close
setts=nothing文件天生
iferr.number0orerrthen%>
<scriptlanguage="javascript">
alert("不克不及完成")
</script>
<%else%>
<scriptlanguage="javascript">
alert("已完成")
history.back();
</script>
<%endif
SetMyFile=fs.GetFile(filez)
all_tree2=server.mappath("news")&""&chan_data(now)
if(fs.FolderExists(all_tree2))then
else
fs.CreateFolder(all_tree2)
endif
MyFile.name=left(MyFile.name,len(MyFile.name)-4)&".htm"
setMyFile=nothing
setfs=nothing
setfdir=nothing
functionget_pass(pass)
pass=cstr(pass)
pass=replace(pass,"","")
pass=replace(pass,"","")
pass=replace(pass,"-","")
pass=replace(pass,"","")
pass=replace(pass,":","")
pass=replace(pass,".","")
pass=replace(pass,"+","")
pass=replace(pass,"_","")
pass=replace(pass,"<","")
pass=replace(pass,">","")
pass=replace(pass,"!","")
pass=replace(pass,"@","")
pass=replace(pass,"#","")
pass=replace(pass,"$","")
pass=replace(pass,"%","")
pass=replace(pass,"^","")
pass=replace(pass,"&","")
pass=replace(pass,"*","")
pass=replace(pass,"(","")
pass=replace(pass,")","")
pass=replace(pass,"=","")
pass=replace(pass,"","")
pass=replace(pass,"/","")
pass=replace(pass,"|","")
get_pass=pass
endfunction
%>
因为现在数据库都使用标准的SQL语言对数据库进行管理,所以如果是标准SQL语言,两者基本上都可以通用的。SQLServer还有更多的扩展,可以用存储过程,数据库大小无极限限制。 Server:这个表示的服务器,操作服务器的一些工具使用这个,如Server.Mappath转换服务器路径,Server.CreateObject实例化一个组件 ASP的语言不仅仅只是命令格式差不多,而是包含在<%%>之内的命令完全就是VB语法。虽然ASP也是做为单独的一个技术来提出的,但他就是完全继承了VB所有的功能。 我可以结合自己的经验大致给你说一说,希望对你有所帮助,少走些弯路。 Request:从字面上讲就是“请求”,因此这个是处理客户端提交的东东的,例如Resuest.Form,Request.QueryString,或者干脆Request("变量名") 你可以通过继承已有的对象最大限度保护你以前的投资。并且C#和C++、Java一样提供了完善的调试/纠错体系。 代码逻辑混乱,难于管理:由于ASP是脚本语言混合html编程,所以你很难看清代码的逻辑关系,并且随着程序的复杂性增加,使得代码的管理十分困难,甚至超出一个程序员所能达到的管理能力,从而造成出错或这样那样的问题。 接下来就不能纸上谈兵了,最好的方法其实是实践。实践,只能算是让你掌握语言特性用的。而提倡做实际的Project也不是太好,因为你还没有熟练的能力去综合各种技术,这样只能使你自己越来越迷糊。 封装性使得代码逻辑清晰,易于管理,并且应用到ASP.Net上就可以使业务逻辑和Html页面分离,这样无论页面原型如何改变,业务逻辑代码都不必做任何改动;继承性和多态性使得代码的可重用性大大提高。
页:
[1]