Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

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

Posted on 1999-08-02
8
Medium Priority
?
331 Views
Last Modified: 2013-11-18
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??
0
Comment
Question by:cakkme
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
  • 2
  • +1
8 Comments
 
LVL 33

Expert Comment

by:knightEknight
ID: 1852618
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
%>
0
 

Accepted Solution

by:
davidmiles earned 200 total points
ID: 1852619
You cannot dynamically construct a #include
directive.  However, you may be able to work around this by putting the #includes in an If-Then or Select Case construct.  For example,

Select Case Var1
  Case "file1"
    <!--#include vitrual="/includes/file1.inc"-->
  Case "file2"
    <!--#include virtual="/includes/file2.inc"-->
End Select

This will include both file1.inc and file2.inc, but program flow will be controlled by the Select Case, resulting in only one file's code being executed.
0
 
LVL 10

Expert Comment

by:MasseyM
ID: 1852620
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.
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Expert Comment

by:davidmiles
ID: 1852621
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
0
 
LVL 33

Expert Comment

by:knightEknight
ID: 1852622
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.

0
 

Expert Comment

by:davidmiles
ID: 1852623
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
0
 

Author Comment

by:cakkme
ID: 1852624
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!!.
0
 
LVL 10

Expert Comment

by:MasseyM
ID: 1852625
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...
0

Featured Post

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article demonstrates how to create a simple responsive confirmation dialog with Ok and Cancel buttons using HTML, CSS, jQuery and Promises
Originally, this post was published on Monitis Blog, you can check it here . Websites are getting bigger and more complicated by the day. Video, images and custom fonts are all great for showcasing your product or service. But the price to pay in…
In this tutorial viewers will learn how to embed Flash content in a webpage using HTML5. Ensure your DOCTYPE declaration is set to HTML5: "<!DOCTYPE html>": Use the <object> tag to embed Flash content.: To specify that the object is Flash content, d…
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

715 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question