仓酷云

标题: ASP教程之老外的代码分别举措 [打印本页]

作者: 愤怒的大鸟    时间: 2015-1-16 22:44
标题: ASP教程之老外的代码分别举措
使用filesystemobject,可以对服务器上的文件进行操作,浏览、复制、移动、删除等。有ado的支持,asp对数据库的操作非常得心应手。你甚至可以像使用本地数据库那样,管理远程主机上的数据库,对表格、记录进行各种操作。代码分别index.asp
-----------------------------------------------------------------------
<!--#includefile="templateclass.asp"-->
<%
Thisisthecodeusedtoloadanddisplaythetemplate.
Seehowcleanitis!!!:)
subgo()
dimoTemplate

setoTemplate=newtemplate

withoTemplate
.usetemplate("message.tpl")
.tag("date")=Date()
.tag("self")="<divstyle=background:#dddddd>"&.gettemplate("message.tpl",true)&"</div>"
.tag("aspcode")=.gettemplate("index.asp",false)
.tag("howtouse")=.gettemplate("howtouse.tpl",false)
.display()
endwith

setoTemplate=nothing
endsub
go()
%>

templateclass.asp
------------------------------------------------------------------------
<%
Thisisthetemplateobject.Itallowsthecreation,reading
andeditingoftemplatesontheserver.
CREATEDBY:ChristopherBrown-Floyd
DATE:November3,1999
classtemplate

Thisvariablestoresthetemplate
privatemytemplateasstring

Thismethodgetsatemplatefromtheserverandreturns
thewholefileasastring.
publicfunctiongettemplate(pathfilename,encodetohtml)asstring
dimoFSOasobject
dimoTemplateasobject
dimtemptemplateasstring

Opentypeforthetemplate(read-only)
constforreading=1,boolcreatefile=false

ifIsNull(encodetohtml)orencodetohtml=""orencodetohtml=falsethen
encodetohtml=false
else
encodetohtml=true
endif


onerrorresumenext
Createfilesystemobject
setoFSO=server.createobject("scripting.filesystemobject")

Createtemplateobject
setoTemplate=oFSO.opentextfile(server.mappath(pathfilename),forreading,boolcreatefile)
iferr0then
err.clear
exitfunction
endif
Getthewholefileasastring
temptemplate=oTemplate.readall

EncodetemplatetoHTML?
ifencodetohtmlthen
gettemplate=tohtml(temptemplate)
else
gettemplate=temptemplate
endif

Closethetemplate
oTemplate.close

Freetheserverresources
setoTemplate=nothing

setoFSO=nothing
endfunction


Thisproceduregetsandstoresatemplate
publicsubusetemplate(pathfilename)
thistemplate=gettemplate(pathfilename,false)
endsub


Thispropertyreplacestagswiththeuserstemplate
publicpropertylettag(tagname,userstring)
dimld,rdasstring
dimtemptagasstring
dimtagstart,tagendasinteger

ld="<!--"
rd="-->"
tagstart=1

dowhiletagstart>0andtagstart<len(thistemplate)
tagstart=instr(tagstart,thistemplate,ld)
iftagstart>0then
tagend=instr(tagstart,thistemplate,rd)
iftagend>(tagstart+3)then
temptag=mid(thistemplate,tagstart+4,tagend-(tagstart+4))
if(trim(temptag)=tagname)or(temptag=tagname)then
ifIsNull(userstring)then
thistemplate=replace(thistemplate,ld&temptag&rd,"")
else
thistemplate=replace(thistemplate,ld&temptag&rd,userstring)
endif
exitdo
else
tagstart=tagstart+4
endif
endif
endif
loop
endproperty


publicsubremoveTags()
dimld,rdasstring
dimtemptagasstring
dimtagstart,tagendasinteger

ld="<!--"
rd="-->"
tagstart=1

dowhiletagstart>0andtagstart<len(thistemplate)
tagstart=instr(tagstart,thistemplate,ld)
iftagstart>0then
tagend=instr(tagstart,thistemplate,rd)
iftagend>(tagstart+3)then
temptag=mid(thistemplate,tagstart+4,tagend-(tagstart+4))
thistemplate=replace(thistemplate,ld&temptag&rd,"")
tagstart=tagend
endif
endif
loop
endsub


Thispropertyallowstheusertoassignthecurrenttemplate
publicpropertyletthistemplate(template_as_string)
ifvartype(template_as_string)=vbstring_
orvartype(template_as_string)=vbnullthen
mytemplate=template_as_string
endif
endproperty
</p>对用户来说可预见费用、节约费用,可以做到花少钱办大事。由于省去了购买软件和硬件等的前期费用,用户可以租用较高级的应用软件。ASP的收费是根据软件的类型、客制化程度、用户数量、服务期限来定的,对客户来说这笔费用是可以预见的。方便于客户应用软件的升级。
作者: 莫相离    时间: 2015-1-17 22:06
那么,ASP.Net有哪些改进呢?
作者: 金色的骷髅    时间: 2015-1-21 09:35
ASP.Net摆脱了以前ASP使用脚本语言来编程的缺点,理论上可以使用任何编程语言包括C++,VB,JS等等,当然,最合适的编程语言还是MS为.NetFrmaework专门推出的C(读csharp),它可以看作是VC和Java的混合体吧。
作者: 分手快乐    时间: 2015-1-30 13:36
掌握asp的特性而且一定要知道为什么。
作者: 仓酷云    时间: 2015-2-6 12:55
虽然ASP也有很多网络教程。但是这些都不系统。都是半路出家,只是从一个例子告诉你怎么用。不会深入讨论,更不会将没有出现在例子里的方法都一一列举出来。
作者: 透明    时间: 2015-2-16 03:44
Application:这个存储服务端的数据,如果不清除,会直到web应用程序结束才清除(例如重启站点)
作者: 兰色精灵    时间: 2015-3-4 23:26
用户端的浏览器不需要提供任何别的支持,这样大提高了用户与服务器之间的交互的速度。
作者: 简单生活    时间: 2015-3-11 21:23
先学习用frontpage熟悉html编辑然后学习asp和vbscript建议买书进行系统学习
作者: 爱飞    时间: 2015-3-19 14:08
ASP.Net摆脱了以前ASP使用脚本语言来编程的缺点,理论上可以使用任何编程语言包括C++,VB,JS等等,当然,最合适的编程语言还是MS为.NetFrmaework专门推出的C(读csharp),它可以看作是VC和Java的混合体吧。
作者: 山那边是海    时间: 2015-3-28 08:50
Server:这个表示的服务器,操作服务器的一些东西使用这个,如Server.Mappath转换服务器路径,Server.CreateObject实例化一个组件




欢迎光临 仓酷云 (http://www.ckuyun.com/) Powered by Discuz! X3.2