INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • 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.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Jobs

ASP 101

Dynamic Include Pages - an alternative function by walderr
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: ASP (Active Server Pages) FAQ Index
Back to Microsoft: ASP (Active Server Pages) Forum

My Archive

Resources

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close