ASP file include problem

  • Thread starter Thread starter Andrew Price
  • Start date Start date
A

Andrew Price

This is not ASP.NET, but i am having a problem with old school ASP, what i
need to do is

<% myFileName="incfile.asp" %>

<!--#include file="<% myFileName%>"-->

However when i use this it comes back with the error


Active Server Pages error 'ASP 0126'

Include file not found

/dev/andrewp/temp/test.asp, line 4

The include file '<%myFileName%>' was not found.



Anyone know how to fix it

Thanks

Andrew
 
Hi Andrew,

A server-side include is a pre-processor directive, which means that you
can't do that. The include is processed prior to the script being executed.
Try using Server.Execute instead.

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
The sun never sets on
the Kingdom of Heaven
 
Classic ASP does not allow you to dynamically include files. All include
instructions happen first than IIS prosses all script commands. This means
that at the point in time when you try to include a file that your variable
myFileName does not have a value yet.

For more information check out:
- http://www.learnasp.com/learn/includedynamic.asp
- http://www.aspfaq.com/show.asp?id=2042
- http://www.asp101.com/articles/michael/dynamicincludes/default.asp
- http://www.codefixer.com/tutorials/dynamic_includes.asp
- http://support.microsoft.com/default.aspx?scid=kb;en-us;192144
 
Back
Top