ASP file include problem

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
 
K

Kevin Spencer

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
 
P

pete

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,770
Messages
2,569,583
Members
45,075
Latest member
MakersCBDBloodSupport

Latest Threads

Top