No this can't be done. The reason is because the include statement is executed before the ASP code is actually parsed. So by the time you come to the ASP logic, the file is already included. The only thing you can do is what vasah20 has suggested. What this actually results in, is all three files in vasah20's example are included but only one is effectively used. This is a limitation of ASP and there is no getting around it. Wushutwist
Attention!! This works only with Windows2000/IIS5.0
The way to do that is to use Server.Execute instead of
include. The reason is that the include directive is parsed before execution and even if you have things like that
<%if this = true then%>
<!--#include file="myfile.asp"-->
<%elseif that = true%>
<!--#include file="otherfile.asp"-->
<%else%>
<!--#include file="yourfile.asp"-->
<%end if%>
it include all the files you mention (myfile.asp,otherfile.asp,yourfile.asp) not only what you wish.
With server.Execute it is possible to simulate your needs like so:
<%
if this = true then
Server.Execute "myfile.asp"
elseif that = true
Server.Execute "myfile2.asp"
else
Server.Execute "myfile3.asp"
end if
%>
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.