asp下用實(shí)現(xiàn)模板加載的的幾種方法總結(jié) 原創(chuàng)
原創(chuàng) 更新時(shí)間:2008年01月12日 16:02:23 原創(chuàng) 作者:
asp下html模板的加載方法,一般有以下幾種,大家可以根據(jù)情況自己決定,結(jié)果都是一樣的,都是好方法
1、使用adodb.stream實(shí)現(xiàn)的 一般虛擬主機(jī)都提供
function loadtempletfile(byval path)
on error resume next
dim objstream
set objstream = server.createobject("adodb.stream")
with objstream
.type = 2
.mode = 3
.open
.loadfromfile server.mappath(path)
if err.number <> 0 then
err.clear
response.write("預(yù)加載的模板[" & path & "]不存在!")
response.end()
end if
.charset = "" & chrset & ""
.position = 2
loadtempletfile = .readtext
.close
end with
set objstream = nothing
end function
2、用fso實(shí)現(xiàn)模板的加載速度快,但好多虛擬主機(jī)不提供fso功能
'*******************************************************************************************************
'函數(shù)名:LoadTemplate
'作 用:取出模板內(nèi)容
'參 數(shù):TemplateFname模板地址
'返回值:模板內(nèi)容
'********************************************************************************************************
Function LoadTemplate(TemplateFname)
on error resume next
Dim FSO, FileObj, FileStreamObj
Set FSO = CreateObject("scripting.filesystemobject")
TemplateFname = Server.MapPath(Replace(TemplateFname, "http://", "/"))
If FSO.FileExists(TemplateFname) = False Then
LoadTemplate = "模板不存在,請(qǐng)先綁定!"
Else
Set FileObj = FSO.GetFile(TemplateFname)
Set FileStreamObj = FileObj.OpenAsTextStream(1)
If Not FileStreamObj.AtEndOfStream Then
LoadTemplate = FileStreamObj.ReadAll
Else
LoadTemplate = "模板內(nèi)容為空"
End If
End If
Set FSO = Nothing:Set FileObj = Nothing:Set FileStreamObj = Nothing
LoadTemplate=LoadTemplate & Published
End Function
'**************************************************
ASP使用FSO讀取模板的代碼
3、還有一種就是把模板放到數(shù)據(jù)庫中(速度慢)
復(fù)制代碼 代碼如下:
function loadtempletfile(byval path)
on error resume next
dim objstream
set objstream = server.createobject("adodb.stream")
with objstream
.type = 2
.mode = 3
.open
.loadfromfile server.mappath(path)
if err.number <> 0 then
err.clear
response.write("預(yù)加載的模板[" & path & "]不存在!")
response.end()
end if
.charset = "" & chrset & ""
.position = 2
loadtempletfile = .readtext
.close
end with
set objstream = nothing
end function
2、用fso實(shí)現(xiàn)模板的加載速度快,但好多虛擬主機(jī)不提供fso功能
復(fù)制代碼 代碼如下:
'*******************************************************************************************************
'函數(shù)名:LoadTemplate
'作 用:取出模板內(nèi)容
'參 數(shù):TemplateFname模板地址
'返回值:模板內(nèi)容
'********************************************************************************************************
Function LoadTemplate(TemplateFname)
on error resume next
Dim FSO, FileObj, FileStreamObj
Set FSO = CreateObject("scripting.filesystemobject")
TemplateFname = Server.MapPath(Replace(TemplateFname, "http://", "/"))
If FSO.FileExists(TemplateFname) = False Then
LoadTemplate = "模板不存在,請(qǐng)先綁定!"
Else
Set FileObj = FSO.GetFile(TemplateFname)
Set FileStreamObj = FileObj.OpenAsTextStream(1)
If Not FileStreamObj.AtEndOfStream Then
LoadTemplate = FileStreamObj.ReadAll
Else
LoadTemplate = "模板內(nèi)容為空"
End If
End If
Set FSO = Nothing:Set FileObj = Nothing:Set FileStreamObj = Nothing
LoadTemplate=LoadTemplate & Published
End Function
'**************************************************
ASP使用FSO讀取模板的代碼
3、還有一種就是把模板放到數(shù)據(jù)庫中(速度慢)
相關(guān)文章
asp中利用xmlhttp抓取網(wǎng)頁內(nèi)容的代碼
抓取網(wǎng)頁。偶要實(shí)現(xiàn)實(shí)實(shí)更新天氣預(yù)報(bào)。利用了XMLHTTP組件,抓取網(wǎng)頁的指定部分,其實(shí)很多的小偷程序要更好用2012-10-10ASP利用Google實(shí)現(xiàn)在線翻譯功能
ASP利用Google實(shí)現(xiàn)在線翻譯功能...2006-09-09ASP讀取XML實(shí)例 優(yōu)酷專輯采集程序 雷鋒版
用asp獲取指定專題的xml文件,然后讀取xml文件的列表內(nèi)容批量讀取。2009-12-12ASP調(diào)用WebService轉(zhuǎn)化成JSON數(shù)據(jù),附j(luò)son.min.asp
接觸WebService也很久了,但是使用asp調(diào)用教程的卻不多,還有轉(zhuǎn)成json也不多見,本文全部分享給大家,需要的拿去吧。2016-03-03關(guān)于ASP循環(huán)表格的問題之解答[比較詳細(xì)]
在很多時(shí)候,我們采用原始的方法來解決一行內(nèi)循環(huán)3張圖片,如果上傳者只上傳了2張圖片,那么2張圖片間的距離會(huì)很大,因?yàn)槿鄙倭艘粋€(gè)<td> </td>.2008-11-11