欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

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ī)都提供
復(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)文章

最新評(píng)論