Problem with include files!

Discussion in 'ASP General' started by Julesh, Jun 22, 2006.

  1. Julesh

    Julesh Guest

    Hello,

    I am new to ASP and am trying to make some changes to some ASP 3.0 code
    I have inherited.

    I have a number of ASP pages with VBS as the base language, on each of
    these pages I have successfully included a piece of VBS code that
    produces output in a table cell by using:

    <!--#include file="showAnswers.inc" -->

    I have added a new page to the site where the base language is
    JavaScript. If I try to use the same include line there it doesn't work
    as it correctly detects that the code in the include file is written in
    VBScript not JavaScript.

    So I tried...

    <Script language="VBScript" src="showAnswers.inc" </Script>

    The page runs in the browser without error but the code in the include
    file isn't included so I don't get the output I expect.

    So i try...


    <Script language="VBScript" src="showAnswers.inc" RUNAT="server"></Script>

    The include now works but the output of the included code appears at the
    top of the output, not in the table cell where I want it.

    I have no idea how to resolve this. Can anyone help?



    Thanks


    Jules
     
    Julesh, Jun 22, 2006
    #1
    1. Advertising

  2. Julesh

    Jeff Guest

    weird. i have now run into the same problem. some of my includes work, and
    some are not.
    i moved the same files into a subweb, and they work there.
    wondering what's up with that.



    "Julesh" <> wrote in message
    news:DhFmg.472903$...
    > Hello,
    >
    > I am new to ASP and am trying to make some changes to some ASP 3.0 code I
    > have inherited.
    >
    > I have a number of ASP pages with VBS as the base language, on each of
    > these pages I have successfully included a piece of VBS code that produces
    > output in a table cell by using:
    >
    > <!--#include file="showAnswers.inc" -->
    >
    > I have added a new page to the site where the base language is JavaScript.
    > If I try to use the same include line there it doesn't work as it
    > correctly detects that the code in the include file is written in VBScript
    > not JavaScript.
    >
    > So I tried...
    >
    > <Script language="VBScript" src="showAnswers.inc" </Script>
    >
    > The page runs in the browser without error but the code in the include
    > file isn't included so I don't get the output I expect.
    >
    > So i try...
    >
    >
    > <Script language="VBScript" src="showAnswers.inc" RUNAT="server"></Script>
    >
    > The include now works but the output of the included code appears at the
    > top of the output, not in the table cell where I want it.
    >
    > I have no idea how to resolve this. Can anyone help?
    >
    >
    >
    > Thanks
    >
    >
    > Jules
     
    Jeff, Jun 23, 2006
    #2
    1. Advertising

  3. well,

    mixing server side javascript and vbscript in the same code is seldom a good
    idea

    your learning that

    best to stick to one or the other I say..

    I have fooled around with mixing the two and only got very simple things to
    work correctly at best




    "Julesh" <> wrote in message
    news:DhFmg.472903$...
    > Hello,
    >
    > I am new to ASP and am trying to make some changes to some ASP 3.0 code I
    > have inherited.
    >
    > I have a number of ASP pages with VBS as the base language, on each of
    > these pages I have successfully included a piece of VBS code that produces
    > output in a table cell by using:
    >
    > <!--#include file="showAnswers.inc" -->
    >
    > I have added a new page to the site where the base language is JavaScript.
    > If I try to use the same include line there it doesn't work as it
    > correctly detects that the code in the include file is written in VBScript
    > not JavaScript.
    >
    > So I tried...
    >
    > <Script language="VBScript" src="showAnswers.inc" </Script>
    >
    > The page runs in the browser without error but the code in the include
    > file isn't included so I don't get the output I expect.
    >
    > So i try...
    >
    >
    > <Script language="VBScript" src="showAnswers.inc" RUNAT="server"></Script>
    >
    > The include now works but the output of the included code appears at the
    > top of the output, not in the table cell where I want it.
    >
    > I have no idea how to resolve this. Can anyone help?
    >
    >
    >
    > Thanks
    >
    >
    > Jules
     
    Kyle Peterson, Jun 23, 2006
    #3
  4. "Julesh" <> wrote in message
    news:DhFmg.472903$...
    > Hello,
    >
    > I am new to ASP and am trying to make some changes to some ASP 3.0 code
    > I have inherited.
    >
    > I have a number of ASP pages with VBS as the base language, on each of
    > these pages I have successfully included a piece of VBS code that
    > produces output in a table cell by using:
    >
    > <!--#include file="showAnswers.inc" -->
    >


    A poor design choice on the part of the original development.

    > I have added a new page to the site where the base language is
    > JavaScript. If I try to use the same include line there it doesn't work
    > as it correctly detects that the code in the include file is written in
    > VBScript not JavaScript.
    >
    > So I tried...
    >
    > <Script language="VBScript" src="showAnswers.inc" </Script>
    >


    This just tries to run the contents of the include on the client. (Use of
    inc extension allows the client to download the file content another poor
    choice.)

    > The page runs in the browser without error but the code in the include
    > file isn't included so I don't get the output I expect.
    >
    > So i try...
    >
    >
    > <Script language="VBScript" src="showAnswers.inc" RUNAT="server"></Script>
    >


    I'm suprised this works at all. It normally isn't possible to use an ASP
    include as a VBScript source, this include is likely to at least have a
    couple of <% %> delimiters which are invalid in VBScript. In order to this
    to work these delimiters would need to be removed but then all the other
    normal uses of the include would break.

    There is another problem with this approach when the specified language
    isn't the same as the page language. The content will not be executed in
    line but will executed before the rest of the page has been processed.

    > The include now works but the output of the included code appears at the
    > top of the output, not in the table cell where I want it.
    >
    > I have no idea how to resolve this. Can anyone help?
    >


    The easiest solution is to stop using JScript as your base language.

    If you really must use JScript then the only solution I can see is leave the
    page as VBScript and place all your JScript in a:-

    <script language="JScript" runat="Server">
    ..
    ..
    ..
    </script>

    block at the top of your page. Note that this should contain pure Jscript,
    no inline HTML, also any code that generates output to the response should
    be inside functions. You then call the functions from the pages VBScript
    language at the point you need them.

    Anthony.

    >
    >
    > Thanks
    >
    >
    > Jules
     
    Anthony Jones, Jun 23, 2006
    #4
  5. Julesh

    Evertjan. Guest

    Kyle Peterson wrote on 23 jun 2006 in
    microsoft.public.inetserver.asp.general:

    > mixing server side javascript and vbscript in the same code is seldom
    > a good idea
    >


    I think it is a very viable idea, I use it often.

    I use vbs as the main script, and JS only to define certain functions.

    Especially small regex test functions are much easier written in JS,
    [once you get the hang of it!!!]:

    <% 'vbscript main

    .......

    if NOT testPassword(passw) then ...

    %>

    <script language='javascript' runat='server'>
    // contains at least 1 letter char and 1 number char?
    function testPassword(x){
    return /\d/.test(x) && /[a-z]/i.test(x)
    }
    </script>


    --
    Evertjan.
    The Netherlands.
    (Please change the x'es to dots in my emailaddress)
     
    Evertjan., Jun 23, 2006
    #5
  6. Julesh

    Evertjan. Guest

    Anthony Jones wrote on 23 jun 2006 in
    microsoft.public.inetserver.asp.general:

    > If you really must use JScript then the only solution I can see is
    > leave the page as VBScript and place all your JScript in a:-
    >
    > <script language="JScript" runat="Server">
    > .
    > .
    > .
    > </script>
    >
    > block at the top of your page.


    The position in the file [not "page"] does not matter,
    since in a vbs-asp file the JS-runats are executed first anyway.

    > Note that this should contain pure Jscript,
    > no inline HTML, also any code that generates output to the response
    > should be inside functions.


    A easy advice, since _inline_ html IN a runat='..' is not possible anyway.

    response.write('Hello world'); is possible, but it seems better to stick to
    function definitions.






    --
    Evertjan.
    The Netherlands.
    (Please change the x'es to dots in my emailaddress)
     
    Evertjan., Jun 23, 2006
    #6
  7. "Evertjan." <> wrote in message
    news:Xns97EB5F4D2C027eejj99@194.109.133.242...
    > Kyle Peterson wrote on 23 jun 2006 in
    > microsoft.public.inetserver.asp.general:
    >
    > > mixing server side javascript and vbscript in the same code is seldom
    > > a good idea
    > >

    >
    > I think it is a very viable idea, I use it often.
    >
    > I use vbs as the main script, and JS only to define certain functions.
    >
    > Especially small regex test functions are much easier written in JS,
    > [once you get the hang of it!!!]:
    >


    That's interesting point of view. I'm not sure I'd want to ask ASP to run
    JScript as well as VBScript for sake of a few lines of code. Also the
    JScript implementation of RegExp gets annoying when you want to run a global
    match with submatches.

    > <% 'vbscript main
    >
    > ......
    >
    > if NOT testPassword(passw) then ...
    >
    > %>
    >
    > <script language='javascript' runat='server'>
    > // contains at least 1 letter char and 1 number char?
    > function testPassword(x){
    > return /\d/.test(x) && /[a-z]/i.test(x)
    > }
    > </script>
    >
    >
    > --
    > Evertjan.
    > The Netherlands.
    > (Please change the x'es to dots in my emailaddress)
     
    Anthony Jones, Jun 23, 2006
    #7
  8. "Evertjan." <> wrote in message
    news:Xns97EB61956F2C2eejj99@194.109.133.242...
    > Anthony Jones wrote on 23 jun 2006 in
    > microsoft.public.inetserver.asp.general:
    >
    > > If you really must use JScript then the only solution I can see is
    > > leave the page as VBScript and place all your JScript in a:-
    > >
    > > <script language="JScript" runat="Server">
    > > .
    > > .
    > > .
    > > </script>
    > >
    > > block at the top of your page.

    >
    > The position in the file [not "page"]


    Has anyone ever pointed out to you how painfully pedantic you are

    >does not matter,
    > since in a vbs-asp file the JS-runats are executed first anyway.
    >


    True but since it does get executed first you may as well put it first just
    to be clear.

    > > Note that this should contain pure Jscript,
    > > no inline HTML, also any code that generates output to the response
    > > should be inside functions.

    >
    > A easy advice, since _inline_ html IN a runat='..' is not possible anyway.


    Which is why I said don't do it.

    >
    > response.write('Hello world'); is possible, but it seems better to stick

    to
    > function definitions.
    >
    >
    >
    >
    >
    >
    > --
    > Evertjan.
    > The Netherlands.
    > (Please change the x'es to dots in my emailaddress)
     
    Anthony Jones, Jun 23, 2006
    #8
  9. Julesh

    Evertjan. Guest

    Anthony Jones wrote on 23 jun 2006 in
    microsoft.public.inetserver.asp.general:
    >> > If you really must use JScript then the only solution I can see is
    >> > leave the page as VBScript and place all your JScript in a:-
    >> >
    >> > <script language="JScript" runat="Server">
    >> > </script>
    >> >
    >> > block at the top of your page.


    >> The position in the file [not "page"]

    >
    > Has anyone ever pointed out to you how painfully pedantic you are


    Why do you snear when you are corrected? Bad day, Anthony?

    Many mistakes are a result of the misconseption, that ASP-"pages" exist.

    >> does not matter,
    >> since in a vbs-asp file the JS-runats are executed first anyway.


    > True but since it does get executed first you may as well put it first
    > just to be clear.


    As well? I don't think so, I like to have my simple function definitions
    at the bottom out of the way, as I treat them as reusable black boxes.

    It is a personal preference, which I would advocate as useful.

    >> > Note that this should contain pure Jscript,
    >> > no inline HTML, also any code that generates output to the response
    >> > should be inside functions.

    >>
    >> A easy advice, since _inline_ html IN a runat='..' is not possible
    >> anyway.

    >
    > Which is why I said don't do it.


    Isn't advising not to do what is impossible to do anyway a bit strange?

    --
    Evertjan.
    The Netherlands.
    (Please change the x'es to dots in my emailaddress)
     
    Evertjan., Jun 23, 2006
    #9
  10. "Evertjan." <> wrote in message
    news:Xns97EB6AB4191F2eejj99@194.109.133.242...
    > Anthony Jones wrote on 23 jun 2006 in
    > microsoft.public.inetserver.asp.general:
    > >> > If you really must use JScript then the only solution I can see is
    > >> > leave the page as VBScript and place all your JScript in a:-
    > >> >
    > >> > <script language="JScript" runat="Server">
    > >> > </script>
    > >> >
    > >> > block at the top of your page.

    >
    > >> The position in the file [not "page"]

    > >
    > > Has anyone ever pointed out to you how painfully pedantic you are

    >
    > Why do you snear when you are corrected? Bad day, Anthony?
    >


    Yeah I kinda snapped seeing yet another 'correction' from of something which
    really doesn't need correcting.

    > Many mistakes are a result of the misconseption, that ASP-"pages" exist.


    Such as?

    >
    > >> does not matter,
    > >> since in a vbs-asp file the JS-runats are executed first anyway.

    >
    > > True but since it does get executed first you may as well put it first
    > > just to be clear.

    >
    > As well? I don't think so, I like to have my simple function definitions
    > at the bottom out of the way, as I treat them as reusable black boxes.
    >
    > It is a personal preference, which I would advocate as useful.
    >


    Fair enough.

    > >> > Note that this should contain pure Jscript,
    > >> > no inline HTML, also any code that generates output to the response
    > >> > should be inside functions.
    > >>
    > >> A easy advice, since _inline_ html IN a runat='..' is not possible
    > >> anyway.

    > >
    > > Which is why I said don't do it.

    >
    > Isn't advising not to do what is impossible to do anyway a bit strange?
    >


    Not when the original poster is clearly not sure what is and isn't
    impossible.

    > --
    > Evertjan.
    > The Netherlands.
    > (Please change the x'es to dots in my emailaddress)
     
    Anthony Jones, Jun 23, 2006
    #10
  11. Well, didn't mean to start a mini post war guys.
    I guess my personal preference is that I don't find it useful and I guess I
    am not a perfy enough programmer to really give a crap either way...

    It's friday and I am going to the bar to see how much beer I can drink!



    "Anthony Jones" <> wrote in message
    news:%23HV%...
    >
    > "Evertjan." <> wrote in message
    > news:Xns97EB6AB4191F2eejj99@194.109.133.242...
    >> Anthony Jones wrote on 23 jun 2006 in
    >> microsoft.public.inetserver.asp.general:
    >> >> > If you really must use JScript then the only solution I can see is
    >> >> > leave the page as VBScript and place all your JScript in a:-
    >> >> >
    >> >> > <script language="JScript" runat="Server">
    >> >> > </script>
    >> >> >
    >> >> > block at the top of your page.

    >>
    >> >> The position in the file [not "page"]
    >> >
    >> > Has anyone ever pointed out to you how painfully pedantic you are

    >>
    >> Why do you snear when you are corrected? Bad day, Anthony?
    >>

    >
    > Yeah I kinda snapped seeing yet another 'correction' from of something
    > which
    > really doesn't need correcting.
    >
    >> Many mistakes are a result of the misconseption, that ASP-"pages" exist.

    >
    > Such as?
    >
    >>
    >> >> does not matter,
    >> >> since in a vbs-asp file the JS-runats are executed first anyway.

    >>
    >> > True but since it does get executed first you may as well put it first
    >> > just to be clear.

    >>
    >> As well? I don't think so, I like to have my simple function definitions
    >> at the bottom out of the way, as I treat them as reusable black boxes.
    >>
    >> It is a personal preference, which I would advocate as useful.
    >>

    >
    > Fair enough.
    >
    >> >> > Note that this should contain pure Jscript,
    >> >> > no inline HTML, also any code that generates output to the response
    >> >> > should be inside functions.
    >> >>
    >> >> A easy advice, since _inline_ html IN a runat='..' is not possible
    >> >> anyway.
    >> >
    >> > Which is why I said don't do it.

    >>
    >> Isn't advising not to do what is impossible to do anyway a bit strange?
    >>

    >
    > Not when the original poster is clearly not sure what is and isn't
    > impossible.
    >
    >> --
    >> Evertjan.
    >> The Netherlands.
    >> (Please change the x'es to dots in my emailaddress)

    >
    >
     
    Kyle Peterson, Jun 23, 2006
    #11
  12. Julesh

    Patrice Guest

    The include directive doesn't care about the language. IMO it would be
    rather that you have to put inside your include file a runat="server" script
    tag that explicitely tells that you are using VBScript... (my understanding
    is that "it doesn't work as it correctly detects" means it's not running
    fine as the VB Script is thought to be JavaScript code).

    --
    Patrice

    "Julesh" <> a écrit dans le message de news:
    DhFmg.472903$...
    > Hello,
    >
    > I am new to ASP and am trying to make some changes to some ASP 3.0 code I
    > have inherited.
    >
    > I have a number of ASP pages with VBS as the base language, on each of
    > these pages I have successfully included a piece of VBS code that produces
    > output in a table cell by using:
    >
    > <!--#include file="showAnswers.inc" -->
    >
    > I have added a new page to the site where the base language is JavaScript.
    > If I try to use the same include line there it doesn't work as it
    > correctly detects that the code in the include file is written in VBScript
    > not JavaScript.
    >
    > So I tried...
    >
    > <Script language="VBScript" src="showAnswers.inc" </Script>
    >
    > The page runs in the browser without error but the code in the include
    > file isn't included so I don't get the output I expect.
    >
    > So i try...
    >
    >
    > <Script language="VBScript" src="showAnswers.inc" RUNAT="server"></Script>
    >
    > The include now works but the output of the included code appears at the
    > top of the output, not in the table cell where I want it.
    >
    > I have no idea how to resolve this. Can anyone help?
    >
    >
    >
    > Thanks
    >
    >
    > Jules
     
    Patrice, Jun 23, 2006
    #12
  13. Anthony Jones wrote:
    >> The position in the file [not "page"]

    > Has anyone ever pointed out to you how painfully pedantic you are


    They have, but that does not mean his pedantry is unwelcome. In this case,
    the distinction between "file" (personally, I would have said "script") and
    "page" is the very essence of the issue. The <script runat="server"> tag
    will *never* appear in the output, or page.



    --
    Dave Anderson

    Unsolicited commercial email will be read at a cost of $500 per message. Use
    of this email address implies consent to these terms.
     
    Dave Anderson, Jun 23, 2006
    #13
  14. "Dave Anderson" <> wrote in message
    news:%23Gy8S$...
    > Anthony Jones wrote:
    > >> The position in the file [not "page"]

    > > Has anyone ever pointed out to you how painfully pedantic you are

    >
    > They have, but that does not mean his pedantry is unwelcome. In this case,
    > the distinction between "file" (personally, I would have said "script")

    and
    > "page" is the very essence of the issue.


    The only entity I can see that I refered to as a 'page' is the ASP 'file'.
    Honestly why is that a problem?

    >The <script runat="server"> tag
    > will *never* appear in the output, or page.
    >
    >
    >
    > --
    > Dave Anderson
    >
    > Unsolicited commercial email will be read at a cost of $500 per message.

    Use
    > of this email address implies consent to these terms.
    >
    >
     
    Anthony Jones, Jun 23, 2006
    #14
  15. Julesh

    Mike Brind Guest

    Re: Problem with include files!

    Anthony Jones wrote:
    > "Dave Anderson" <> wrote in message
    > news:%23Gy8S$...
    > > Anthony Jones wrote:
    > > >> The position in the file [not "page"]
    > > > Has anyone ever pointed out to you how painfully pedantic you are

    > >
    > > They have, but that does not mean his pedantry is unwelcome. In this case,
    > > the distinction between "file" (personally, I would have said "script")

    > and
    > > "page" is the very essence of the issue.

    >
    > The only entity I can see that I refered to as a 'page' is the ASP 'file'.
    > Honestly why is that a problem?
    >


    I don't understand the importance of the differentiation either. It
    seems to me that "asp file" and "asp page" are used interchangeably to
    mean the same thing, even by Microsoft:
    http://www.microsoft.com/windows200...indows2000/en/server/iis/htm/asp/iiwauslw.htm
    but I would be interested to know why this is an issue.

    --
    Mike Brind
     
    Mike Brind, Jun 23, 2006
    #15
    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. Danny Anderson
    Replies:
    5
    Views:
    530
    Victor Bazarov
    Aug 15, 2003
  2. Rolf Magnus
    Replies:
    2
    Views:
    629
    Karl Heinz Buchegger
    Nov 28, 2003
  3. Elie Nader
    Replies:
    1
    Views:
    666
  4. web4all
    Replies:
    0
    Views:
    3,188
    web4all
    May 11, 2006
  5. Andreas Bogenberger
    Replies:
    3
    Views:
    1,011
    Andreas Bogenberger
    Feb 22, 2008
Loading...

Share This Page