Print Page | Close Window

Dynamic Includes

Printed From: Web Wiz Forums
Category: General Discussion
Forum Name: Classic ASP Discussion
Forum Description: Discussion on Active Server Pages (Classic ASP).
URL: https://forums.webwiz.net/forum_posts.asp?TID=3471
Printed Date: 30 March 2026 at 3:03am
Software Version: Web Wiz Forums 12.08 - https://www.webwizforums.com


Topic: Dynamic Includes
Posted By: FatOtis
Subject: Dynamic Includes
Date Posted: 12 June 2003 at 6:47am

Having found out that I can't use variables for dynamic includes using the   <!--#INCLUDE file="<% =var %>"-->   method I decided to go looking up dynamic include script on the net, I found a few of sample scripts but havent had any luck getting anything to work, can anyone help me with this?




Replies:
Posted By: stephen
Date Posted: 12 June 2003 at 7:55am

http://www.4guysfromrolla.com/webtech/010700-1.shtml - http://www.4guysfromrolla.com/webtech/010700-1.shtml

Server.Execute "pagename.asp" Could work as well.

also if there are say two possible values for varaiable var, u could try:

<% If var = "one" Then %>

<!--#INCLUDE file="firstpage.asp"-->

Else

IF var = "two" Then %>

<!--#INCLUDE file="secondpage.asp"-->

End if

End if

where firstpage.asp and secondpage.asp contain the asp code for the variabls. Actually in this case, it's best to use select Case statements.



Posted By: ultramods
Date Posted: 12 June 2003 at 8:25am

Or you could use:

server.execute("yourPage.asp")



Posted By: Mart
Date Posted: 12 June 2003 at 10:09am
He is asking for a variable you cant use <%server.execute(var1)%> it causes an error...


Posted By: FatOtis
Date Posted: 12 June 2003 at 10:15am

Yer basically, what I'm trying to do is make my site skinable, if you know any other methods please let me know.

Basically how I want it to work is:

varSkin = Read SkinName from cookie

Include header called varSkin



Posted By: stephen
Date Posted: 13 June 2003 at 3:10am

FatOtis doesn't this method work

<%

var1 =Request.Cookies("Skin")("value")

server.execute("skinFile.asp?type=var1")

%>

?



Posted By: michael
Date Posted: 13 June 2003 at 1:09pm

Of course you can use variables in server.execute something like
var1 = "folder/file.asp"
Server.Execute var1
would work.
Anyway, I don't think server.execute would work would for skins and the option stephen supplied first may take up quite a bit of space, as all code would be processed. You could store the actual code in a database and just print the code needed for your skin or use some component that does real dynamic includes.



-------------
http://baumannphoto.com" rel="nofollow - Blog | http://mpgtracker.com" rel="nofollow - MPG Tracker


Posted By: FatOtis
Date Posted: 14 June 2003 at 5:00am
Yea, I'll have a fiddle around and see what happens, thanks for the help guys.


Posted By: dpyers
Date Posted: 16 June 2003 at 12:07am

You can't pass variables through an include statement, however, any variables available to the page that contains the include statement are available to the included page.

e.g. page1.asp includes page2.asp

If you call page1.asp as -  page1.asp?MyVar=x

MyVar is available in page2.asp

I use something similar for handling logins to return them to the initial page they tried to access.

 



-------------

Lead me not into temptation... I know the short cut, follow me.


Posted By: pmormr
Date Posted: 16 June 2003 at 5:39pm

that's impossible. thats like saying that your going to mail somthing somewhere and the address is avaliable at the destination, ain't gonna happen.



-------------
Paul A Morgan

http://www.pmorganphoto.com/" rel="nofollow - http://www.pmorganphoto.com/


Posted By: fernan82
Date Posted: 16 June 2003 at 6:22pm
Originally posted by pmormr pmormr wrote:

that's impossible. thats like saying that your going to mail somthing somewhere and the address is avaliable at the destination, ain't gonna happen.

He/she just posted an example of how to pass the var from page1 to page2 and he said that the var will be available on page two, not that the var is on page 2, so it is possible, however it won't help to make the site skinnable......



-------------
FeRnAN
http://www.danasoft.com/">


Posted By: pmormr
Date Posted: 17 June 2003 at 11:25am
oh, i misunderstood you. you want to pass a variable to page 2 from page1. I though you wanted to use a variable from page two to redirect to page two. Sorry.

-------------
Paul A Morgan

http://www.pmorganphoto.com/" rel="nofollow - http://www.pmorganphoto.com/


Posted By: FatOtis
Date Posted: 20 June 2003 at 2:55am

Should This Work:

 

<%
Dim SkinNo
SkinNo = Request.Cookies("Skin")

If SkinNo <> "" Then
 SkinNo = "1"
 Response.Cookies("Skin") = "1"
Else
  SkinNo = Request.Cookies("Skin")
End If

Response.Write ("Skin:"& SkinNo)
Server.Execute("skin/"& SkinNo &"/header.inc")
%>

    <!--#INCLUDE file="pagecontent.inc" -->


<% Server.Execute("skin/"& SkinNo &"/footer.inc") %>

 

    ...becasue it dosent


 



Posted By: Bluefrog
Date Posted: 20 June 2003 at 10:35am

Why not just skin it with CSS? Or just use the script at http://alistapart.com - http://alistapart.com for skins (again CSS)?

Select... Case  works better than If... Then...



Posted By: FatOtis
Date Posted: 20 June 2003 at 12:16pm

Fine then...

<%
Dim SkinNo
Dim SkinChange

SkinNo = Request.Cookies("Skin")

SkinChange = CLng(Request.QueryString("skin"))

If SkinChange <> "" Then
     Response.Cookies("Skin") = SkinChange
     SkinNo = SkinChange
End If

Select Case SkinNo
  Case 1
     Response.Cookies("Skin") = 1
     Server.Execute("skin/1/header.inc")
  Case 2
     Response.Cookies("Skin") = 2
     Server.Execute("skin/2/header.inc")
  Case Else
     Response.Write ("No Skin Selected"& SkinNo)
     SkinNo = CLng(Request.QueryString("Skin"))
     'Response.Cookies("Skin") = SkinNo
End Select


Response.Write (SkinChange &" - SkinChange <br>")
Response.Write (Skin &" - Skin <br>")

%>

 

...and yeah, I'll prboally just go with CSS skining, I mainly just wanted to see if it could be done. It would appear not.




Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.08 - https://www.webwizforums.com
Copyright ©2001-2026 Web Wiz Ltd. - https://www.webwiz.net