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 Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Include file as variable 1

Status
Not open for further replies.

Niv3k

Programmer
Jul 11, 2001
350
US
I am playing around with making an include tag as a variable. I have four different pages I want it to link to, and I want to use an if...then or select case to include the file.

For example if X=1, then I want to include One.asp, but if it is 2, I want to include two.asp...

Any ideas?
 
Have you tried:


<%If X=1 Then%>
<!-- #include FILE=&quot;one.asp&quot; -->
<%End If%>
<%If X=2 Then%>
<!-- #include FILE=&quot;two.asp&quot; -->
<%End If%>

ect.....


This should work for what you are talking about. You could also use the Select Case syntax if you wanted. Hope this helps......
 
The syntax for using select case would look something like:


<%Select Case X
Case &quot;1&quot;%>
<!-- #include FILE=&quot;one.asp&quot; -->
<%Case &quot;2&quot;%>
<!-- #include FILE=&quot;two.asp&quot; -->
<%End Select%>


 
Being as there are four different pages, the Select Case made more sense. Thanks!

Kevin
 
Hi,

Sorry jitter but your example is not quite correct.
If you do
<%Select Case X
Case &quot;1&quot;%>
<!-- #include FILE=&quot;one.asp&quot; -->
<%Case &quot;2&quot;%>
<!-- #include FILE=&quot;two.asp&quot; -->
<%End Select%>
iis will include both files because #include is a directive resolved before the execution of the page.
The only way to do dynamic include is to use one of Server.Execute (only IIS 5.0).
When iis find a server.execute transfer excution to that script. After that it return execution to original script. It's a a kind of sub(function) situated in a different file.

Important note: when IIS transfer execution to the second asp page it keeps the content of Request collection so you may use it.

Hope this help.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top