How to dynamically include code

Hi,

When a user requests my asp page It will look at the documentID parameter, my database will return the code snippets that had to be visible then. But the problem is that you can't use a dynamic parameter to an include statement. Who knows how I can include the includefiles returned from my database?

Thanks a lot in advance,

Roderik

Comments

  • [b][red]This message was edited by Moderator at 2002-9-17 2:46:57[/red][/b][hr]
    : Hi,
    :
    : When a user requests my asp page It will look at the documentID parameter, my database will return the code snippets that had to be visible then. But the problem is that you can't use a dynamic parameter to an include statement. Who knows how I can include the includefiles returned from my database?
    :
    : Thanks a lot in advance,
    :
    : Roderik
    :

    Assumed that the database will return you a value, then you can pass the value as the parameter inside a Response.Write() codes?

    E.g.
    [code]
    <%
    If returnCode = 1 Then
    Response.Write("<!--#include file='" & returnCode & "'-->")
    End If
    %>
    [/code]
    [size=2]Neo Gigs[/size]
    [color=blue]http://communities.msn.com.my/VisualBasicwithNeo[/color]



  • Are you sure that will work since includes are normally handles before the other scripting. Since there is no include found before the server goes to the other scripting it can't include I think. But I will give it a try.

    : [b][red]This message was edited by Moderator at 2002-9-17 2:46:57[/red][/b][hr]
    : : Hi,
    : :
    : : When a user requests my asp page It will look at the documentID parameter, my database will return the code snippets that had to be visible then. But the problem is that you can't use a dynamic parameter to an include statement. Who knows how I can include the includefiles returned from my database?
    : :
    : : Thanks a lot in advance,
    : :
    : : Roderik
    : :
    :
    : Assumed that the database will return you a value, then you can pass the value as the parameter inside a Response.Write() codes?
    :
    : E.g.
    : [code]
    : <%
    : If returnCode = 1 Then
    : Response.Write("<!--#include file='" & returnCode & "'-->")
    : End If
    : %>
    : [/code]
    : [size=2]Neo Gigs[/size]
    : [color=blue]http://communities.msn.com.my/VisualBasicwithNeo[/color]
    :
    :
    :
    :

  • The include line is generated as HTML include tag, so the response.write should be executed before other response.write that output HTML tags.

    As we know that it is supposed to be in the first line of any HTML codes but NOT asp page right?


    [size=2]Neo Gigs[/size]
    [color=blue]http://communities.msn.com.my/VisualBasicwithNeo[/color]

  • You cannot write INCLUDE tags with ASP, but one way of getting around this is to include a special asp-file instead which in its turn redirects to the desired include-file:

    1) Declare a global variable (e.g incFile) and assign to it the filename of the include-file (as received from your database)

    2) Include the asp-file as described above.

    3) In this asp-file redirect, response.redirect incFile

    /Chris
  • [b][red]This message was edited by vanith at 2002-9-20 8:4:40[/red][/b][hr]
    [b][red]This message was edited by vanith at 2002-9-20 8:4:23[/red][/b][hr]
    Hi!

    If you are using ASP 3.0, your problem is solved with Server.execute(filename), which does exactly what you require in this case.

    :)heers,
    Vanith



  • : Hi,
    :
    : When a user requests my asp page It will look at the documentID parameter, my database will return the code snippets that had to be visible then. But the problem is that you can't use a dynamic parameter to an include statement. Who knows how I can include the includefiles returned from my database?
    :
    : Thanks a lot in advance,
    :
    : Roderik
    :

    Hello

    Did you get to do it ?

    I tried the suggestions over here (include file, server.execute) but
    none of them run fine



  • : : Hi,
    : :
    : : When a user requests my asp page It will look at the documentID parameter, my database will return the code snippets that had to be visible then. But the problem is that you can't use a dynamic parameter to an include statement. Who knows how I can include the includefiles returned from my database?
    : :
    : : Thanks a lot in advance,
    : :
    : : Roderik
    : :
    :
    : Hello
    :
    : Did you get to do it ?
    :
    : I tried the suggestions over here (include file, server.execute) but
    : none of them run fine
    :
    :
    :
    :
    Yeah, it works fine with Server.Execute()

    [hr]
    [red]The 100[/red] best Dutch [blue]websites (free participation):[/blue]
    :-) http://www.top100nederland.tk/

  • : [b][red]This message was edited by vanith at 2002-9-20 8:4:40[/red][/b][hr]
    : [b][red]This message was edited by vanith at 2002-9-20 8:4:23[/red][/b][hr]
    : Hi!
    :
    : If you are using ASP 3.0, your problem is solved with Server.execute(filename), which does exactly what you require in this case.
    :
    : :)heers,
    : Vanith
    :
    :
    :

    but this only runs if I put like:

    server.execute(file.txt)

    but , what if I want to put like this:

    dim file

    file = request.form(filename)

    but this file isn't in the current directory.. .like the
    script is on /scripts/download and the file is at /downloads

    what can I do to get the file from

    server.execute(/downloads/file.txt)

    this doesn't runs

    is there another option?
    :

  • : : Hi!
    : :
    : : If you are using ASP 3.0, your problem is solved with Server.execute(filename), which does exactly what you require in this case.
    : :
    : : :)heers,
    : : Vanith
    : :
    : :
    : :
    :
    : but this only runs if I put like:
    :
    : server.execute(file.txt)
    :
    : but , what if I want to put like this:
    :
    : dim file
    :
    : file = request.form(filename)
    :
    : but this file isn't in the current directory.. .like the
    : script is on /scripts/download and the file is at /downloads
    :
    : what can I do to get the file from
    :
    : server.execute(/downloads/file.txt)
    :
    : this doesn't runs
    :
    : is there another option?
    : :
    :

    Why shud not this work? as long as you pass the correct path to your file as argument (and you are using ASP 3.0. I understand you have ASP 3.0 when you said it worked for the files in the current directory).

    OK Just try this out.
    [code]
    dim sFilename
    sFilename = "/downloads/file.txt"
    Response.write Server.Mappath(sFilename)
    [/code]

    If you are able to get the correct physical path of the file thru Server.Mappath [Say c:inetpubwwwrootdownloads], it should work fine with Server.Execute..

    :)heers,
    Vanith



Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories