Howdy, Stranger!

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

Categories

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

  • gigsvoogigsvoo Member Posts: 328
    [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]



  • rodemmrodemm Member Posts: 44
    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]
    :
    :
    :
    :

  • gigsvoogigsvoo Member Posts: 328
    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]

  • Anjuna MoonAnjuna Moon Member Posts: 89
    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
  • vanithvanith Member Posts: 44
    [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



  • marcoskn1marcoskn1 Member Posts: 61
    : 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



  • rodemmrodemm Member Posts: 44
    : : 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/

  • marcoskn1marcoskn1 Member Posts: 61
    : [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?
    :

  • vanithvanith Member Posts: 44
    : : 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



  • Shawn CarterShawn Carter Member Posts: 0

    __ [ http://forcoder.org ] free ebooks and video tutorials about ( Swift, R, C#, Delphi, Go, Visual Basic, C, C++, Scratch, Java, Python, PHP, MATLAB, Ruby, PL/SQL, Objective-C, Visual Basic .NET, Perl, JavaScript, Assembly Scheme, Awk, ML, Clojure, Logo, Prolog, Ada, D, COBOL, Kotlin, FoxPro, Crystal, Transact-SQL, Fortran, Erlang, Lua, Bash, Lisp, Scala, Hack, Alice, VBScript, Apex, Dart, F#, Julia, LabVIEW, Rust, ABAP, SAS ) __

Sign In or Register to comment.