INTELLIGENT WORK FORUMS FOR COMPUTER PROFESSIONALS
Come Join Us!
- Talk With Other Members
- Be Notified Of Responses
To Your Posts
- Keyword Search
- Turn Off Ad Banners
- One-Click Access To Your
Favorite Forums
- Automated Signatures
On Your Posts
- Best Of All, It's Free!
*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.
Partner With Us!
"Best Of Breed" Forums Add Stickiness To Your Site

(Download This Button Today!)
Member Feedback
"...Keep up the good work - excellent site - i'd been looking for something like this for ages !..."
Geography
Where in the world do Tek-Tips members come from?
|
Microsoft: Active Server Pages (ASP) FAQ
|
ASP 101
|
Dynamic Include Pages - an alternative function
Posted: 4 Sep 03
|
After thinking it was impossible to include .asp pages dynamically, I've managed to crack a way of doing it, which although technically not an 'include' method, uses the Server.Execute function to get round the problem as follows:
On the main page you wish to view, use the function Server.Execute "Folder/"&Variable&".asp" where you want it to appear - this will 'include' the relevant file.
On the page you are including, if you wish to execute asp within it, you can use the following method under some circumstances: Make sure that the variable is taken to the main page in a query string, ie the address off the main page will be in the format mainpage.asp?my_var=<%=my_var%>
On the included page, use QueryString = Request.ServerVariables("QUERY_STRING") This takes the variables from the url of the main page (eg my_var=<%=my_var%> in the above example). You can then chop this up so that the particular variable you want is taken for use in the include page (eg my_var).
In short:
MAIN------------------------------- mainpage.asp?my_var=<%=my_var%> Server.Execute "Folder/"&Variable&".asp"
INCLUDE---------------------------- QueryString = Request.ServerVariables("QUERY_STRING") Cut = split(QueryString,"=") Paste = ubound(Cut) - lbound(Cut) + 1 my_var = (Cut(Paste-1))
And there you have it. The variable can now do its job on the included asp page, which sits inside the main asp page. Very simple, but it worked for me! |
Back to Microsoft: Active Server Pages (ASP) FAQ Index
Back to Microsoft: Active Server Pages (ASP) Forum
My FAQ Archive
Email This FAQ To A Friend |
|
 |
|