Home All Groups Group Topic Archive Search About

include file according to a parameter



Author
18 Jul 2006 1:53 AM
lucky
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

Author
18 Jul 2006 2:16 AM
lucky
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.
Author
18 Jul 2006 6:46 AM
Anthony Jones
Show quote
"lucky" <lfe***@nordnet.fr> wrote in message
news:1153187584.444342.174890@m73g2000cwd.googlegroups.com...
> 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?

Show quote
> many thanks
>
> Luc
>
Author
18 Jul 2006 9:41 AM
Aaron Bertrand [SQL Server MVP]
> 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

AddThis Social Bookmark Button