Include file with param

Discussion in 'ASP General' started by TNG, Jun 9, 2005.

  1. TNG

    TNG Guest

    Hi,

    I try to accomplish something like this:

    <!--#include file="menu_<%response.write (strproduct)%>.html"-->

    But unfortunally, I quess there is something with my syntax... any idea ?
     
    TNG, Jun 9, 2005
    #1
    1. Advertising

  2. TNG

    Adrienne Guest

    Gazing into my crystal ball I observed "TNG" <> writing in
    news:SUQpe.114741$-ops.be:

    > Hi,
    >
    > I try to accomplish something like this:
    >
    ><!--#include file="menu_<%response.write (strproduct)%>.html"-->
    >
    > But unfortunally, I quess there is something with my syntax... any idea
    > ?
    >


    The include is processed before ASP code is processed, and therefore does
    not have access to any variables.

    What you might want to do is something like:

    <% select case request.querystring("page")
    case "apples"%>
    <!--#include file="menu_apples.html"-->
    <% case "oranges"%>
    <!--#include file="menu_oranges.html"-->
    <% case else%>
    <!--#include file="menu_default.html"-->
    <% end select%>

    --
    Adrienne Boswell
    http://www.cavalcade-of-coding.info
    Please respond to the group so others can share
     
    Adrienne, Jun 9, 2005
    #2
    1. Advertising

  3. TNG

    Roland Hall Guest

    "TNG" wrote in message
    news:SUQpe.114741$-ops.be...
    : I try to accomplish something like this:
    :
    : <!--#include file="menu_<%response.write (strproduct)%>.html"-->
    :
    : But unfortunally, I quess there is something with my syntax... any idea ?

    The include file executes for the ASP processor. The only way I know to use
    an include file dynamically is to use server.execute.

    I have an example:

    Run this alone and it will report it's virtual path:
    http://kiddanger.com/lab/serverdotexec.asp

    Run it with ?q=a, ?q=b or ?q=c and it will also include the appropriate
    file.

    Here's the code:
    <%@ Language=VBScript %>
    <%
    Option Explicit
    Response.Buffer = True

    dim q
    q =
    server.HTMLEncode(replace(replace(replace(Request.QueryString("q"),"'","''"),";",""),"--",""))

    Response.Write Request.ServerVariables("SCRIPT_NAME") & "<br />" & vbCrLf

    if q <> "" Then
    select case q
    case "a"
    server.execute "/lab/serverdotexeca.asp"
    case "b"
    server.execute "/lab/serverdotexecb.asp"
    case "c"
    server.execute "/lab/serverdotexecc.asp"
    case else
    Response.Write "Nice try!"
    Response.End
    end select
    end if
    %>

    This is serverdotexeca.asp. b and c are similar.

    <%@ Language=VBScript %>
    <%
    Option Explicit
    Response.Buffer = True
    Response.Write "This is serverdotexeca.asp<br />" & vbCrLf
    %>

    HTH...

    --
    Roland Hall
    /* This information is distributed in the hope that it will be useful, but
    without any warranty; without even the implied warranty of merchantability
    or fitness for a particular purpose. */
    Technet Script Center - http://www.microsoft.com/technet/scriptcenter/
    WSH 5.6 Documentation - http://msdn.microsoft.com/downloads/list/webdev.asp
    MSDN Library - http://msdn.microsoft.com/library/default.asp
     
    Roland Hall, Jun 9, 2005
    #3
  4. TNG

    TNG Guest

    Thx
    "Adrienne" <> wrote in message
    news:Xns966FEE71D3275arbpenyahoocom@207.115.63.158...
    > Gazing into my crystal ball I observed "TNG" <> writing in
    > news:SUQpe.114741$-ops.be:
    >
    >> Hi,
    >>
    >> I try to accomplish something like this:
    >>
    >><!--#include file="menu_<%response.write (strproduct)%>.html"-->
    >>
    >> But unfortunally, I quess there is something with my syntax... any idea
    >> ?
    >>

    >
    > The include is processed before ASP code is processed, and therefore does
    > not have access to any variables.
    >
    > What you might want to do is something like:
    >
    > <% select case request.querystring("page")
    > case "apples"%>
    > <!--#include file="menu_apples.html"-->
    > <% case "oranges"%>
    > <!--#include file="menu_oranges.html"-->
    > <% case else%>
    > <!--#include file="menu_default.html"-->
    > <% end select%>
    >
    > --
    > Adrienne Boswell
    > http://www.cavalcade-of-coding.info
    > Please respond to the group so others can share
     
    TNG, Jun 9, 2005
    #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. Robert Mark Bram

    jsp include and jsp param

    Robert Mark Bram, Sep 8, 2005, in forum: Java
    Replies:
    2
    Views:
    6,022
    Robert Mark Bram
    Sep 12, 2005
  2. Geathaa
    Replies:
    2
    Views:
    726
    Geathaa
    Jul 30, 2003
  3. ectoplasm
    Replies:
    12
    Views:
    669
    Zorro
    Jul 28, 2005
  4. Andreas Bogenberger
    Replies:
    3
    Views:
    1,003
    Andreas Bogenberger
    Feb 22, 2008
  5. Dave
    Replies:
    5
    Views:
    750
    John Bokma
    Apr 26, 2011
Loading...

Share This Page