include file according to a parameter

Discussion in 'ASP General' started by lucky, Jul 18, 2006.

  1. lucky

    lucky Guest

    Hi

    I need to include a file within a page but the address of the included
    file depends on a parameter

    So I wrote something like this:


    <!--#include virtual="/<%=FolderName%>/includes/includefile.asp"-->
    where FolderName is a variable containing a string.

    But this doesn't work. It seems that you can't build an include link
    with ASP.
    And I can't test the value of my variable since I will have many
    possible values and some new ones will be added regularly.

    Is there a way to do this?

    many thanks

    Luc
    lucky, Jul 18, 2006
    #1
    1. Advertising

  2. lucky

    lucky Guest

    I also tried this:


    DIM filespec, fs, f, content
    filespec = Server.MapPath("/" & FolderName & "/logos.asp")
    set fs = CreateObject("Scripting.FileSystemObject")
    set f = fs.OpenTextFile(filespec)
    content = f.ReadAll()
    set f = nothing
    set fs = nothing

    Response.Write(content)

    But the ASP code in then displayed as plain text.
    lucky, Jul 18, 2006
    #2
    1. Advertising

  3. "lucky" <> wrote in message
    news:...
    > Hi
    >
    > I need to include a file within a page but the address of the included
    > file depends on a parameter
    >
    > So I wrote something like this:
    >
    >
    > <!--#include virtual="/<%=FolderName%>/includes/includefile.asp"-->
    > where FolderName is a variable containing a string.
    >
    > But this doesn't work. It seems that you can't build an include link
    > with ASP.
    > And I can't test the value of my variable since I will have many
    > possible values and some new ones will be added regularly.
    >
    > Is there a way to do this?
    >


    No. Can you rearrange things so that instead of using an include you can
    use a Server.Execute?

    > many thanks
    >
    > Luc
    >
    Anthony Jones, Jul 18, 2006
    #3
  4. > I need to include a file within a page but the address of the included
    > file depends on a parameter
    >
    > So I wrote something like this:
    >
    >
    > <!--#include virtual="/<%=FolderName%>/includes/includefile.asp"-->


    This does not work, because the <!--#include directive is processed BEFORE
    any code in <%%>.

    http://www.aspfaq.com/2042
    Aaron Bertrand [SQL Server MVP], Jul 18, 2006
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Victor Bazarov

    #include "file" -vs- #include <file>

    Victor Bazarov, Mar 5, 2005, in forum: C++
    Replies:
    4
    Views:
    525
    Exits Funnel
    Mar 6, 2005
  2. PTM
    Replies:
    1
    Views:
    319
    Andy Dingley
    Nov 12, 2007
  3. naveeddil
    Replies:
    0
    Views:
    552
    naveeddil
    Jan 4, 2008
  4. Andreas Bogenberger
    Replies:
    3
    Views:
    885
    Andreas Bogenberger
    Feb 22, 2008
  5. Borr
    Replies:
    1
    Views:
    141
    Dino Chiesa [Microsoft]
    Oct 28, 2003
Loading...

Share This Page