《拓文asp.net网站内容管理系统》官方演示站。
 设为首页  
 收藏本站
 作者:黄振安
 QQ:53854651
首 页 开源拓文.NET编程网站编程网页设计图形图像数据库软件工程留言本
    站内搜索:  
您现在的位置: 拓文网络 → 网站编程 → ASP → asp动态include文件[正文]

热 门 文 章

相 关 文 章
  • ASP.NET性能优化
  • ASP脚本循环语句
  • 在.NET框架应用程序中发送电子邮件
  • .net打包自动安装数据库
  • asp.net开发wap必备:更好的匹配手机设备
  • 用ashx动态生成文件
  • windows 2003下asp.Net站点无法使用用户名+密码的方
  • ASP.NET中17种正则表达式
  • 提高ASP.Net应用程序性能的十大方法
  • 一个通过web.Mail发送邮件的类
  • asp动态include文件
     
    [作者:不详    转贴自:不详    点击数:    更新时间:2006-3-13 8:48:09]

    受<!-- #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")
    首页 | 1 | 尾页  共 1 页
     
    hch004 打印本页 关闭窗口

         文 章 评 论
    评论人 查看该文章的评论 发表时间
       笔 名* : 0 50分 60分 70分 80分 90分 100分
    评论内容 *: (最多1000字。当前字数:0)


    没有相关评论,欢迎您参与!

    - 关于本站 - 网站帮助 - 下载声明 - 友情连接 - 网站地图 -
    Copyright © 2005-2006 myTopWin.Com. All Rights Reserved . [桂ICP备06004496号]