手机
当前位置:查字典教程网 >编程开发 >ASP教程 >asp下用实现模板加载的的几种方法总结 原创
asp下用实现模板加载的的几种方法总结 原创
摘要:1、使用adodb.stream实现的一般虚拟主机都提供复制代码代码如下:functionloadtempletfile(byvalpath...

1、使用adodb.stream实现的一般虚拟主机都提供

复制代码 代码如下:

functionloadtempletfile(byvalpath)

onerrorresumenext

dimobjstream

setobjstream=server.createobject("adodb.stream")

withobjstream

.type=2

.mode=3

.open

.loadfromfileserver.mappath(path)

iferr.number<>0then

err.clear

response.write("预加载的模板["&path&"]不存在!")

response.end()

endif

.charset=""&chrset&""

.position=2

loadtempletfile=.readtext

.close

endwith

setobjstream=nothing

endfunction

2、用fso实现模板的加载速度快,但好多虚拟主机不提供fso功能

复制代码 代码如下:

'*******************************************************************************************************

'函数名:LoadTemplate

'作用:取出模板内容

'参数:TemplateFname模板地址

'返回值:模板内容

'********************************************************************************************************

FunctionLoadTemplate(TemplateFname)

onerrorresumenext

DimFSO,FileObj,FileStreamObj

SetFSO=CreateObject("scripting.filesystemobject")

TemplateFname=Server.MapPath(Replace(TemplateFname,"//","/"))

IfFSO.FileExists(TemplateFname)=FalseThen

LoadTemplate="模板不存在,请先绑定!"

Else

SetFileObj=FSO.GetFile(TemplateFname)

SetFileStreamObj=FileObj.OpenAsTextStream(1)

IfNotFileStreamObj.AtEndOfStreamThen

LoadTemplate=FileStreamObj.ReadAll

Else

LoadTemplate="模板内容为空"

EndIf

EndIf

SetFSO=Nothing:SetFileObj=Nothing:SetFileStreamObj=Nothing

LoadTemplate=LoadTemplate&Published

EndFunction

'**************************************************

ASP使用FSO读取模板的代码

3、还有一种就是把模板放到数据库中(速度慢)

【asp下用实现模板加载的的几种方法总结 原创】相关文章:

ASP中利用execute实现动态包含文件的方法

asp中实现随机分组程序的代码

用asp实现无组件生成验证码的方法2种

asp获取用户真实IP地址的方法

asp下tag的实现,简单介绍与部分代码

asp获取数据库的连接属性的方法

在ASP中调用存储过程的几种方法

asp下多个域名后缀同时查询的域名查询系统

ASP调用带参数存储过程的几种方式

asp实现获取MSSQL数据库表指定条件行数的函数

精品推荐
分类导航