Include file issue

Discussion in 'ASP General' started by Steve Wofford, Oct 27, 2005.

  1. Why can't I get the following running???

    <%
    Dim GetODBCdsn
    GetODBCdsn = <!--#include virtual="\connections\sqlconnection.txt" -->
    Response.Write(GetODBCdsn)
    %>

    TIA,

    Steve
     
    Steve Wofford, Oct 27, 2005
    #1
    1. Advertising

  2. Steve Wofford

    Steven Burn Guest

    Because you are mis-using the #include tag. It's a client-side tag, not a
    server side (you also cannot assign it to a var....)

    If you want your var to hold the string(s) contained within the file, you
    need to first open and read the file, THEN assign the string(s) to your var.

    http://aspfaq.com/show.asp?id=2039

    --
    Regards

    Steven Burn
    Ur I.T. Mate Group
    www.it-mate.co.uk

    Keeping it FREE!

    "Steve Wofford" <> wrote in message
    news:#$...
    > Why can't I get the following running???
    >
    > <%
    > Dim GetODBCdsn
    > GetODBCdsn = <!--#include virtual="\connections\sqlconnection.txt" -->
    > Response.Write(GetODBCdsn)
    > %>
    >
    > TIA,
    >
    > Steve
    >
    >
     
    Steven Burn, Oct 27, 2005
    #2
    1. Advertising

  3. Steve Wofford

    Evertjan. Guest

    Steve Wofford wrote on 27 okt 2005 in
    microsoft.public.inetserver.asp.general:

    > Why can't I get the following running???
    >
    > <%
    > Dim GetODBCdsn
    > GetODBCdsn = <!--#include virtual="\connections\sqlconnection.txt" -->


    includes cannot sit inside <% %> and [so] have no output.

    > Response.Write(GetODBCdsn)
    > %>


    --
    Evertjan.
    The Netherlands.
    (Replace all crosses with dots in my emailaddress)
     
    Evertjan., Oct 27, 2005
    #3
  4. Steve Wofford

    Evertjan. Guest

    Steven Burn wrote on 27 okt 2005 in
    microsoft.public.inetserver.asp.general:
    > Because you are mis-using the #include tag. It's a client-side tag, not a
    > server side (you also cannot assign it to a var....)


    I strongly disagree, Steven.

    <!--#include virtual="\blahDir\blahFile.asp" -->

    is serverside

    and can [and most often does in my case] contain ASP level code that is
    executed inline with other asp code in the master file.

    <%
    a = 1
    %>
    <!--#include virtual="\adder.asp" -->
    <% 'vbscript
    response.write a
    ' this will write 2 to the rendered html output stream,
    ' if adder.asp contains <% a = a+1 %>
    %>


    --
    Evertjan.
    The Netherlands.
    (Replace all crosses with dots in my emailaddress)
     
    Evertjan., Oct 27, 2005
    #4
  5. Steve Wofford

    Steven Burn Guest

    hehe, I know, what I meant was, the #include tag itself is client-side (i.e.
    cannot be encased in the <% %> tags), irrespective of what code the included
    file does or does not have, it cannot be treat in the same manner.

    Hope I'm making sense? (made sense to me whilst I was writing the
    reply....lol (I knew what I meant anyway)).

    --
    Regards

    Steven Burn
    Ur I.T. Mate Group
    www.it-mate.co.uk

    Keeping it FREE!

    "Evertjan." <> wrote in message
    news:Xns96FCD98508D11eejj99@194.109.133.242...
    > Steven Burn wrote on 27 okt 2005 in
    > microsoft.public.inetserver.asp.general:
    > > Because you are mis-using the #include tag. It's a client-side tag, not

    a
    > > server side (you also cannot assign it to a var....)

    >
    > I strongly disagree, Steven.
    >
    > <!--#include virtual="\blahDir\blahFile.asp" -->
    >
    > is serverside
    >
    > and can [and most often does in my case] contain ASP level code that is
    > executed inline with other asp code in the master file.
    >
    > <%
    > a = 1
    > %>
    > <!--#include virtual="\adder.asp" -->
    > <% 'vbscript
    > response.write a
    > ' this will write 2 to the rendered html output stream,
    > ' if adder.asp contains <% a = a+1 %>
    > %>
    >
    >
    > --
    > Evertjan.
    > The Netherlands.
    > (Replace all crosses with dots in my emailaddress)
    >
     
    Steven Burn, Oct 27, 2005
    #5
  6. Steve Wofford

    Patrice Guest

    #include is not part of VBScript but a server directive. Though you could
    try %><!etc..><%, I don't find very clear to include "fragments". I would
    rather include a file that contains a whole constant declaration :

    <!--#include virtual="/somewhere/settings.inc"-->
    <%
    Response.Write ConnectionString
    'My code
    %>

    Const ConnectionString="Whatever"
    being in the settings.inc file...

    Additonaly you'll be able to add other constants to this file if needed...
    --

    "Steve Wofford" <> a écrit dans le message de
    news:%23$...
    > Why can't I get the following running???
    >
    > <%
    > Dim GetODBCdsn
    > GetODBCdsn = <!--#include virtual="\connections\sqlconnection.txt" -->
    > Response.Write(GetODBCdsn)
    > %>
    >
    > TIA,
    >
    > Steve
    >
    >
     
    Patrice, Oct 28, 2005
    #6
    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. Victor Bazarov

    #include "file" -vs- #include <file>

    Victor Bazarov, Mar 5, 2005, in forum: C++
    Replies:
    4
    Views:
    538
    Exits Funnel
    Mar 6, 2005
  2. PTM
    Replies:
    1
    Views:
    333
    Andy Dingley
    Nov 12, 2007
  3. naveeddil
    Replies:
    0
    Views:
    581
    naveeddil
    Jan 4, 2008
  4. Andreas Bogenberger
    Replies:
    3
    Views:
    932
    Andreas Bogenberger
    Feb 22, 2008
  5. Eric
    Replies:
    10
    Views:
    475
Loading...

Share This Page