I can't work it out!

W

Waldy

Hi there,
I am scratching my head over this issue that does not make
sense. Maybe someone here can shed some light on it. I have two .ASP
files, (we'll call them file1.asp and file2.asp) that both include another
file that is declared within a script tag like below:

<SCRIPT LANGUAGE='JavaScript'>
<!-- #include file='includes/include1.asp' -->

There is also some .ASP code in the file that is not in a function or sub
that get run at the server. For some reason that I can't work out, the .ASP
code in the included files does not get run when it is included in file1.asp
but works fine when it is included in file2.asp. If however, I debug the
code and I step into file1.asp then the included code also runs. What is
going on here?
 
M

Michael Kujawa

Is the Includes folder off of the root?
if so use "virtual" instead of "file" in the include statement
 
W

Waldy

Michael Kujawa said:
Is the Includes folder off of the root?
if so use "virtual" instead of "file" in the include statement

Hi there,
thanks for replying. "Includes" is a folder off of the root.
I will try your suggestion, but it does not explain why the include files
code is only executed when I step into file1.asp but the code included in
file2.asp works fine.
 
M

Michael Kujawa

Well you do not need a script tag to include an asp page
the Include tag is sufficient.

<SCRIPT LANGUAGE='JavaScript'>
<!-- #include file='includes/include1.asp' -->

You did however add </script> on both pages correct or it
is contained within the include.asp. Is the include1.asp actually
an asp snippet or a javascript snippet?

If an javascript snippet why use an include statement at all?
<Script Language='Javascript' src="./includes/include1.asp" >
</script>
 
E

Evertjan.

Michael Kujawa wrote on 05 jun 2006 in
microsoft.public.inetserver.asp.general:
Well you do not need a script tag to include an asp page
the Include tag is sufficient.

<SCRIPT LANGUAGE='JavaScript'>

<!-- #include file='includes/include1.asp' -->

You did however add </script> on both pages correct or it
is contained within the include.asp. Is the include1.asp actually
an asp snippet or a javascript snippet?

If an javascript snippet why use an include statement at all?
<Script Language='Javascript' src="./includes/include1.asp" >
</script>

<script type='text/javascript'>
<!-- #include file="includes/include1.asp" -->
</script>

will be loaded every time the page in question is loaded,
because to the client it is onpage code.

===============

<script type='text/javascript' src='includes/include1.asp'>
</script>

however, the include file could be cached clientside for repeated use in
that and other pages.

===============

if include1.asp contains serverside dynamic code, use the first option,
otherwise the second,
reducing server load and downloading time, is preferable.
 
W

Waldy

Michael Kujawa said:
Well you do not need a script tag to include an asp page
the Include tag is sufficient.

<SCRIPT LANGUAGE='JavaScript'>
<!-- #include file='includes/include1.asp' -->

You did however add </script> on both pages correct or it
is contained within the include.asp. Is the include1.asp actually
an asp snippet or a javascript snippet?

If an javascript snippet why use an include statement at all?
<Script Language='Javascript' src="./includes/include1.asp" >
</script>

The file contains JavaScript plus some .ASP that is used to create some of
the JavaScript code.
 
W

Waldy

Hi Evertjan,
I suspected that some sort of caching may be going on
here. So you are saying that I should change the script tag from

<script language='Javascript' >

to

<script type='text/javascript'>

to fix the problem?
 
M

Michael Kujawa

I see....
Evertjan's second option is the one you want

<script type='text/javascript'>
<!-- #include file="includes/include1.asp" -->
</script>


I myself generally do not do that

I just use an #include statement and if there is javascript
I am writing I insert the <script></script> tags inside
the include file

Mike
 
W

Waldy

Evertjan. said:
<script type='text/javascript'>
<!-- #include file="includes/include1.asp" -->
</script>

will be loaded every time the page in question is loaded,
because to the client it is onpage code.

===============

<script type='text/javascript' src='includes/include1.asp'>
</script>

however, the include file could be cached clientside for repeated use in
that and other pages.

===============

if include1.asp contains serverside dynamic code, use the first option,
otherwise the second,
reducing server load and downloading time, is preferable.

I tried that but it made no difference. I am correct in thinking that when
pages are cached, the first time the page is requested the server runs the
code to construct the HTML and then on subsequent requests just sends the
previously constructed HTML instead of running the .ASP?
 
E

Evertjan.

Waldy wrote on 05 jun 2006 in microsoft.public.inetserver.asp.general:
Hi Evertjan,
I suspected that some sort of caching may be going on
here. So you are saying that I should change the script tag from

<script language='Javascript' >

to

<script type='text/javascript'>

to fix the problem?

[please always quote on usenet]

No, but that does not mean you should use ancient code
 
E

Evertjan.

Waldy wrote on 05 jun 2006 in microsoft.public.inetserver.asp.general:
I tried that but it made no difference. I am correct in thinking that
when pages are cached, the first time the page is requested the server
runs the code to construct the HTML and then on subsequent requests
just sends the previously constructed HTML instead of running the
.ASP?

I am trying to explain the differences, not fixing your problem that
probably lies in the way your include1.asp is configured or placed in the
server.

What you could do is change to root referenced urls in stead of your
releative ones.

<!--#include virtual ="/blah/includes/include1.asp"-->
or
<script type='text/javascript' src='/blah/includes/include1.asp'>

Did you use <base href=''> somewhere?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,141
Messages
2,570,817
Members
47,367
Latest member
mahdiharooniir

Latest Threads

Top