中易网

<!-- #include file="../inc/Class.asp" -->连接问题

答案:2  悬赏:60  
解决时间 2021-01-18 10:37
  • 提问者网友:欲望失宠
  • 2021-01-17 09:51
<!-- #include file="../inc/Class.asp" -->连接问题
最佳答案
  • 二级知识专家网友:旧脸谱
  • 2021-01-17 10:17
用简单的循环实现动态包含是不行的,这儿有个不错的方法,用函数实现:

<%
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")
或者 include(你的文件名变量)
全部回答
  • 1楼网友:末日狂欢
  • 2021-01-17 11:25
for i=1 to 10
response.write "<!-- #include file="../inc/Class"&i&".asp" -->"
next
应该就行了
我要举报
如以上回答内容为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
点此我要举报以上问答信息!
大家都在看
推荐信息