源码资源
 
Photoshop
 
     

ASP动态include文件
加入日期: 2006-2-18     关键字: 动态,include
文章来源: CSDN     文章作者: 秋水无恨     责任编辑: 第七乐章
添加收藏夹    打印此页    关闭窗口
  收藏此页到  365Key网摘  天极网摘  博采文摘  和讯网摘  人人网摘

    受<! #include file="filename.asp" --> 宏限制
    必须存在该文件并且会预先编译(不管前面是否加以条件)

    经常有这样的要求,根据不同的需求要求include不同的文件
    如各个人的不同设置,所以要求能动态include文件。

    代码如下:

Function include(filename)
 Dim re,content,fso,f,aspStart,aspEnd
 
 set fso=CreateObject("Scripting.FileSystemObject")
 set f=fso.OpenTextFile(server.mappath(filename))
 content=f.ReadAll
 f.close
 set f=nothing
 set fso=nothing
 
 set re=new RegExp
 re.pattern="^\s*="
 aspEnd=1
 aspStart=inStr(aspEnd,content,"<%")+2
 do while aspStart>aspEnd+1
  Response.write Mid(content,aspEnd,aspStart-aspEnd-2)
  aspEnd=inStr(aspStart,content,"%\>")+2
  Execute(re.replace(Mid(content,aspStart,aspEnd-aspStart-2),"Response.Write "))
  aspStart=inStr(aspEnd,content,"<%")+2
 loop
 Response.write Mid(content,aspEnd) 
 set re=nothing
End Function

使用范例:

include("youinc.asp")


Google搜索 本站


站内搜索:
 





相关文章:
快速导航
 

[VB编程]

系统控制 窗口界面 网络应用 文件操作 图形方面 字符串 多媒体 数据库 其他方面 游戏编写
[网页制作]
制作技巧 建站理念 新手上路 高级应用 ASP技术
[Flash制作教程]
Flash制作
[资源下载]
VB源码下载 建站资源 Flash源码
[沐风软件]
沐风网页三叉戟 下载 注册
  FlashRun 下载 注册
[沐风服务]
域名注册 主机空间 建站服务

关于我们 |  项目合作 | 版权声明  |  | 
闽ICP备05001148号
本站为非盈利性质网站,所开展的一些业务旨在维持网站运转。主机租用、域名注册服务由亿讯网络提供。
沐风经典网友交流群:7738284
©2005 沐风工作室™. 版权所有