Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Including files dynamically

Status
Not open for further replies.

emozley

Technical User
Jan 14, 2003
769
GB
I am trying to include a file that is chosen by using Request.QueryString

<%
Select Case Request.QueryString("displaypage")
Case "chapters/1.htm"
displaypage="chapters/1.htm"
Case "chapters/2.htm"
displaypage="chapters/2.htm"
Case Else
displaypage="chapters/1.htm"
End Select

%>

<!--#include file="<% = displaypage) %>"-->

However I'm getting the following error

Active Server Pages error 'ASP 0126'

Include file not found

/opm/index.asp, line 98

The include file '<% = displaypage) %>' was not found.


What's the best way round this?

Thanks very much

Ed
 
Unfortunatly you cannot include files based on ASP variables. ASP includes files before it starts executing code, basically building one large file in memory before syntax checking and then executing.

Your two easiest options are to either put includes in your case statement or use the Filesystem Object to read the contents of the file yuo need and write them out.

-T

 
There should [!]not[/!] be a close parenthesis on this line.

[tt][blue]<!--#include file="<% = displaypage[!])[/!] %>"-->[/blue][/tt]

-George

Strong and bitter words indicate a weak cause. - Fortune cookie wisdom
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top