Link to home
Start Free TrialLog in
Avatar of cakkme
cakkme

asked on

How can i dynamic-include a page(ASP or Html)?

Hi:
i wanna dynamic include a page at run-time, just like:
======================
<%
  URL=Request("url")
  if URL="" then URL="new.asp"
%>
<!--#include file="<%=URL%>">
============================
as you know, this code dont work.
Can you help me??
Avatar of knightEknight
knightEknight
Flag of United States of America image

If the number of possible values for Request("url") is finite and reasonable, ( no more than 5 or 6 ), it might be easier to just include them all and put code like this in each file -- for example in new.asp:


<%
  If URL = "new.asp" Then

   ...

  End If
%>
ASKER CERTIFIED SOLUTION
Avatar of davidmiles
davidmiles

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of MasseyM
MasseyM

YOu can also read the contents of that file and write it to the browser... That will eliminate the need to KNOW which files you are going to include.
but what if there is script in there to be processed that willnot be if you read the file and send the content to the browser
davidmiles,
even if you put the includes in a case or if-then structure, they are still ALL included.  The only difference between your suggestion and mine is that the if logic is in one place -- which might make things easier to understand from a code-maintenance perspective.

yeah I realise that I was replying to the "YOu can also read the contents of that file and write it to the browser" comment
Avatar of cakkme

ASKER

to MasseyM: if i read an ASP' content, the code in it cannot be run and just output to result page, someone
can "view source" and read my ASP code!!.
That is true.  But, it is a VERY SIMPLE way to "include" a file without having to declare EACH one.  YOu never mentioned that you wanted to include ASP files that needed to be processed before they were included...