Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 6 of 6
  1. #1
    Regular Coder
    Join Date
    Dec 2004
    Location
    Jamaica
    Posts
    592
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Lightbulb Can i pass arguments in include?

    I used the include statement.... it worked fine

    Fine, until I tried to pass queryString arguments into the include syntax it tells me that they cannot find that page. The asp file has no HTML in it, its just a sequence of code that is used on different pages.... But i think there must be a simple reason I must be overlooking


    Please help

  • #2
    Supreme Master coder! glenngv's Avatar
    Join Date
    Jun 2002
    Location
    Philippines
    Posts
    11,042
    Thanks
    0
    Thanked 251 Times in 247 Posts
    Use Server.Execute.

    The Path argument of that method cannot include a query string, however, any query string that was available to the calling ASP page will be available to the called ASP page.

  • #3
    Regular Coder
    Join Date
    Dec 2004
    Location
    Jamaica
    Posts
    592
    Thanks
    2
    Thanked 0 Times in 0 Posts
    B E A UTIFUL!!!!!

    Thanks alot man!!!
    Last edited by jaywhy13; 01-10-2005 at 02:46 AM.

  • #4
    Senior Coder
    Join Date
    Apr 2003
    Location
    England
    Posts
    1,192
    Thanks
    5
    Thanked 13 Times in 13 Posts
    #include, server.execute() and server.transfer() all keep the page state, ie variables are transfered, although this is done in a different way

    #include is pretty much just loading the code into the original page, then processing it all at once. this means that relative items (such as other includes) need to be relative to the main page that it is being called from..there are other differences too but this is the only one i've really noticed

    server.execute() and server.transfer() both transfer the state and run the page separately (server.execute() then transfers the page back again, server.transfer() doesnt) this means that relatives to these pages are relative to the file it is executing, not the file that is calling it (which is useful if you want to make your code available from more than one page

    note: server.execute() and server.transfer() are only available after asp3 but a lot of people think dynamic includes are totally impossible in ASP

    as QueryStrings are just variables in a collection, these are transfered from the main page with the rest of the page state

    one thing that confuses me is that if i have a page that includes a file with common functions in it, then execute to another page, the page being executed cant use the functions that were included from the calling page, ie this:

    functions.asp:
    Code:
    <%
    addThese(intNum1, intNum2)
    	addThese = intNum1 + intNum2
    End Function
    %>
    default.asp:
    Code:
    <!--#include file="functions.asp" -->
    <%
    Response.Write addThese(2, 2)
    strWelcome = "hello"
    Server.Execute("pages/home.asp")
    %>
    pages/home.asp:
    Code:
    <!--#include file="../functions.asp" --><%'This line is needed for this page to be able to call a function, im not sure if server.execute("functions.asp") is any different if it is used on default.asp
    Response.Write strWelcome 'however, this is still here from before
    Response.Write addThese(3, 3)
    %>

  • #5
    Regular Coder
    Join Date
    Jul 2004
    Location
    France
    Posts
    141
    Thanks
    0
    Thanked 0 Times in 0 Posts
    you can also use a very heavy code

    Select case QueryString
    Case 1 %>
    include file 1
    <%Case 2%>
    include file 2

    it is horrible but it works

  • #6
    Regular Coder
    Join Date
    Dec 2004
    Location
    Jamaica
    Posts
    592
    Thanks
    2
    Thanked 0 Times in 0 Posts
    thanks all for your help!!!!
    Here's what worked for me tho....
    I needed the code in the include to know what page I was on, so what I did was to define a variable right before puttin in the include:
    thepage="whatever.asp" and that basically solved my problem.
    It really helped to kno that the include statement includes the code and processes it all at once.... thanks!

    Thanks alot.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •