仓酷云

 找回密码
 立即注册
搜索
热搜: 活动 交友 discuz
查看: 481|回复: 9
打印 上一主题 下一主题

[学习教程] ASP教程之老外的代码分别举措

[复制链接]
愤怒的大鸟 该用户已被删除
跳转到指定楼层
楼主
发表于 2015-1-16 22:44:41 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式

马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。

您需要 登录 才可以下载或查看,没有帐号?立即注册

x
使用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:54 | 只看该作者
那么,ASP.Net有哪些改进呢?
金色的骷髅 该用户已被删除
板凳
发表于 2015-1-21 09:35:37 | 只看该作者
ASP.Net摆脱了以前ASP使用脚本语言来编程的缺点,理论上可以使用任何编程语言包括C++,VB,JS等等,当然,最合适的编程语言还是MS为.NetFrmaework专门推出的C(读csharp),它可以看作是VC和Java的混合体吧。
分手快乐 该用户已被删除
地板
发表于 2015-1-30 13:36:49 来自手机 | 只看该作者
掌握asp的特性而且一定要知道为什么。
5#
发表于 2015-2-6 12:55:29 | 只看该作者
虽然ASP也有很多网络教程。但是这些都不系统。都是半路出家,只是从一个例子告诉你怎么用。不会深入讨论,更不会将没有出现在例子里的方法都一一列举出来。
透明 该用户已被删除
6#
发表于 2015-2-16 03:44:39 | 只看该作者
Application:这个存储服务端的数据,如果不清除,会直到web应用程序结束才清除(例如重启站点)
兰色精灵 该用户已被删除
7#
发表于 2015-3-4 23:26:22 | 只看该作者
用户端的浏览器不需要提供任何别的支持,这样大提高了用户与服务器之间的交互的速度。
简单生活 该用户已被删除
8#
发表于 2015-3-11 21:23:55 | 只看该作者
先学习用frontpage熟悉html编辑然后学习asp和vbscript建议买书进行系统学习
爱飞 该用户已被删除
9#
发表于 2015-3-19 14:08:52 | 只看该作者
ASP.Net摆脱了以前ASP使用脚本语言来编程的缺点,理论上可以使用任何编程语言包括C++,VB,JS等等,当然,最合适的编程语言还是MS为.NetFrmaework专门推出的C(读csharp),它可以看作是VC和Java的混合体吧。
山那边是海 该用户已被删除
10#
发表于 2015-3-28 08:50:23 | 只看该作者
Server:这个表示的服务器,操作服务器的一些东西使用这个,如Server.Mappath转换服务器路径,Server.CreateObject实例化一个组件
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

QQ|Archiver|手机版|仓酷云 鄂ICP备14007578号-2

GMT+8, 2024-5-15 05:25

Powered by Discuz! X3.2

© 2001-2013 Comsenz Inc.

快速回复 返回顶部 返回列表