Connecting Tech Pros Worldwide Help | Site Map

ASP file include problem

Andrew Price
Guest
 
Posts: n/a
#1: Nov 19 '05
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


Kevin Spencer
Guest
 
Posts: n/a
#2: Nov 19 '05

re: ASP file include problem


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

"Andrew Price" <andrew.price@fusionworkshop.com> wrote in message
news:XEKDe.9575$Fx3.9032@newsfe7-gui.ntli.net...[color=blue]
> 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
>
>[/color]


pete
Guest
 
Posts: n/a
#3: Nov 19 '05

re: ASP file include problem


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/micha...es/default.asp
- http://www.codefixer.com/tutorials/dynamic_includes.asp
- http://support.microsoft.com/default...b;en-us;192144


"Andrew Price" <andrew.price@fusionworkshop.com> wrote in message
news:XEKDe.9575$Fx3.9032@newsfe7-gui.ntli.net...[color=blue]
> 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
>
>[/color]


Ozer
Guest
 
Posts: n/a
#4: Nov 19 '05

re: ASP file include problem


Hi Andrew,

Look for usage of Server.Execute(IncludePageName) method.

Bye.


"Andrew Price" wrote:
[color=blue]
> 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
>
>
>[/color]
Closed Thread