469,317 Members | 1,865 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,317 developers. It's quick & easy.

Server-Side Includes

RN1
The book I am referring to learn ASP states the following about server-
side includes:

==============================================
The code in a server-side include file is inserted into the pages that
use it BEFORE the page's ASP code is evaluated. This means that you
can put ASP code inside the include file, and it will be executed like
it was part of the page that includes it. On the other hand, it means
that you cannot use ASP to determine which page to include.
==============================================

But as opposed to the last line in the above para, the following code
makes use of ASP to determine which page to include:

<%
Dim intA,intB

intA=5
intB=6

If(intA>intB) Then
%>
<!-- #include file="File1.inc"-->
<%
Else
%>
<!-- #include file="File2.inc"-->
<%
End If
%>

File1.inc has only one line - This is File1.
Similarly, File2.inc also has only one line - This is File2.

Now since the If condition in the above code evaluates to False,
File2.inc gets included & hence the browser displays

This is File2.

But if I change the value of intA to, say, 10, so that the If
condition evaluates to True, then File1.inc gets included &
consequently the browser displays

This is File1.

So isn't the last line in the above para which I cited from the ASP
book wrong?
Dec 16 '07 #1
10 1595
RN1 wrote:
The book I am referring to learn ASP states the following about
server- side includes:

==============================================
The code in a server-side include file is inserted into the pages that
use it BEFORE the page's ASP code is evaluated. This means that you
can put ASP code inside the include file, and it will be executed like
it was part of the page that includes it. On the other hand, it means
that you cannot use ASP to determine which page to include.
==============================================

But as opposed to the last line in the above para, the following code
makes use of ASP to determine which page to include:

<%
Dim intA,intB

intA=5
intB=6

If(intA>intB) Then
%>
<!-- #include file="File1.inc"-->
<%
Else
%>
<!-- #include file="File2.inc"-->
<%
End If
%>

File1.inc has only one line - This is File1.
Similarly, File2.inc also has only one line - This is File2.

Now since the If condition in the above code evaluates to False,
File2.inc gets included & hence the browser displays

This is File2.

But if I change the value of intA to, say, 10, so that the If
condition evaluates to True, then File1.inc gets included &
consequently the browser displays

This is File1.

So isn't the last line in the above para which I cited from the ASP
book wrong?
No. They are both processed.
http://classicasp.aspfaq.com/files/d...ude-files.html

--
Microsoft MVP - ASP/ASP.NET
Please reply to the newsgroup. This email account is my spam trap so I
don't check it very often. If you must reply off-line, then remove the
"NO SPAM"
Dec 16 '07 #2

"RN1" <rn**@rediffmail.comwrote in message
news:6f**********************************@d27g2000 prf.googlegroups.com...
The book I am referring to learn ASP states the following about server-
side includes:

==============================================
The code in a server-side include file is inserted into the pages that
use it BEFORE the page's ASP code is evaluated. This means that you
can put ASP code inside the include file, and it will be executed like
it was part of the page that includes it. On the other hand, it means
that you cannot use ASP to determine which page to include.
==============================================

But as opposed to the last line in the above para, the following code
makes use of ASP to determine which page to include:

<%
Dim intA,intB

intA=5
intB=6

If(intA>intB) Then
%>
<!-- #include file="File1.inc"-->
<%
Else
%>
<!-- #include file="File2.inc"-->
<%
End If
%>

File1.inc has only one line - This is File1.
Similarly, File2.inc also has only one line - This is File2.

Now since the If condition in the above code evaluates to False,
File2.inc gets included & hence the browser displays

This is File2.

But if I change the value of intA to, say, 10, so that the If
condition evaluates to True, then File1.inc gets included &
consequently the browser displays

This is File1.

So isn't the last line in the above para which I cited from the ASP
book wrong?
According the what the book says your page will look like this before it is
parsed and executed as an ASP page:-

<%
Dim intA,intB

intA=5
intB=6

If(intA>intB) Then
%>
This is File1.
<%
Else
%>
This is File2.
<%
End If
%>

As you can see both includes have been added. Try changing the content of
file2 to this:-

<%
End If
%>
This is File2.
<%
If False Then
%>

The resulting file before parsing becomes:-

<%
Dim intA,intB

intA=5
intB=6

If(intA>intB) Then
%>
This is File1.
<%
Else
%>

<%
End If
%>
This is File2.
<%
If False Then
%>
<%
End If
%>

The resulting output is:-

This is File1.
This is File2.

--
Anthony Jones - MVP ASP/ASP.NET
Dec 16 '07 #3
RN1
On Dec 16, 9:22 pm, "Bob Barrows [MVP]" <reb01...@NOyahoo.SPAMcom>
wrote:
RN1 wrote:
The book I am referring to learn ASP states the following about
server- side includes:
==============================================
The code in a server-side include file is inserted into the pages that
use it BEFORE the page's ASP code is evaluated. This means that you
can put ASP code inside the include file, and it will be executed like
it was part of the page that includes it. On the other hand, it means
that you cannot use ASP to determine which page to include.
==============================================
But as opposed to the last line in the above para, the following code
makes use of ASP to determine which page to include:
<%
Dim intA,intB
intA=5
intB=6
If(intA>intB) Then
%>
<!-- #include file="File1.inc"-->
<%
Else
%>
<!-- #include file="File2.inc"-->
<%
End If
%>
File1.inc has only one line - This is File1.
Similarly, File2.inc also has only one line - This is File2.
Now since the If condition in the above code evaluates to False,
File2.inc gets included & hence the browser displays
This is File2.
But if I change the value of intA to, say, 10, so that the If
condition evaluates to True, then File1.inc gets included &
consequently the browser displays
This is File1.
So isn't the last line in the above para which I cited from the ASP
book wrong?

No. They are both processed.http://classicasp.aspfaq.com/files/d...do-i-dynamical...

--
Microsoft MVP - ASP/ASP.NET
Please reply to the newsgroup. This email account is my spam trap so I
don't check it very often. If you must reply off-line, then remove the
"NO SPAM"- Hide quoted text -

- Show quoted text -
Something's wrong with this newsgroup. The page which lists all the
posts says that there are 3 threads in this post & that Bob & Andrews
have answered my post but I don't find Andrew's response anywhere!!
Dec 17 '07 #4
Something's wrong with this newsgroup. The page which lists all the
posts says that there are 3 threads in this post & that Bob & Andrews
have answered my post but I don't find Andrew's response anywhere!!
Using Thunderbird as my newsreader I see a reply from Bob Barrows and
Anthony Jones, but no Andrews.

Steve
Dec 17 '07 #5
RN1
On Dec 17, 7:24 pm, Dooza <stev...@SPAM.dooza.tvwrote:
Something's wrong with this newsgroup. The page which lists all the
posts says that there are 3 threads in this post & that Bob & Andrews
have answered my post but I don't find Andrew's response anywhere!!

Using Thunderbird as my newsreader I see a reply from Bob Barrows and
Anthony Jones, but no Andrews.

Steve
Ooops sorry.....I meant Anthony....not Andrews :-) I don't use any
newsreader as such....depend on IE6.0.....need to change to Outlook
Express I guess.....

Dec 17 '07 #6
RN1
According the what the book says your page will look like this before it is
parsed and executed as an ASP page:-

<%
Dim intA,intB

intA=5
intB=6

If(intA>intB) Then
%>
This is File1.
<%
Else
%>
This is File2.
<%
End If
%>

As you can see both includes have been added. Try changing the content of
file2 to this:-

<%
End If
%>
This is File2.
<%
If False Then
%>

The resulting file before parsing becomes:-

<%
Dim intA,intB

intA=5
intB=6

If(intA>intB) Then
%>
This is File1.
<%
Else
%>

<%
End If
%>
This is File2.
<%
If False Then
%>
<%
End If
%>

The resulting output is:-

This is File1.
This is File2.

--
Anthony Jones - MVP ASP/ASP.NET
Sorry Anthony but I couldn't exactly understand what are you trying to
say. Could you please be bit more specific on what you are trying to
say?

Thanks
Dec 17 '07 #7
RN1 wrote:
On Dec 17, 7:24 pm, Dooza <stev...@SPAM.dooza.tvwrote:
> Something's wrong with this newsgroup. The page which lists all the
posts says that there are 3 threads in this post & that Bob & Andrews
have answered my post but I don't find Andrew's response anywhere!!

Using Thunderbird as my newsreader I see a reply from Bob Barrows and
Anthony Jones, but no Andrews.

Steve

Ooops sorry.....I meant Anthony....not Andrews :-) I don't use any
newsreader as such....depend on IE6.0.....need to change to Outlook
Express I guess.....
Don't need OE, Thunderbird is better, in my humble opinion. Beats the
life out of web interfaces for newsgroups.

Steve
Dec 17 '07 #8
Sorry Anthony but I couldn't exactly understand what are you trying to
say. Could you please be bit more specific on what you are trying to
say?
Due to the nature of server side includes being processed before the asp
is processed, you can't use this kind of conditional server side includes.

He shows that the page loads both includes first, and then the server
executes the ASP.

Have a look at this: http://www.4guysfromrolla.com/webtech/022504-1.shtml

Steve
Dec 17 '07 #9
RN1
On Dec 17, 9:19 pm, Dooza <stev...@SPAM.dooza.tvwrote:
Sorry Anthony but I couldn't exactly understand what are you trying to
say. Could you please be bit more specific on what you are trying to
say?

Due to the nature of server side includes being processed before the asp
is processed, you can't use this kind of conditional server side includes.

He shows that the page loads both includes first, and then the server
executes the ASP.

Have a look at this:http://www.4guysfromrolla.com/webtech/022504-1.shtml

Steve
OK....fine.....I got it. The bottomline is ALL include files will be
processed (before any ASP code in the ASP page with the includes is
executed) & included in the ASP page irrespective of whether the
include files have been included conditionally or not. Depending on
the If.....Else condition, the appropriate output will be spat out.

Correct?
Dec 17 '07 #10
RN1 wrote:
On Dec 17, 9:19 pm, Dooza <stev...@SPAM.dooza.tvwrote:
>>Sorry Anthony but I couldn't exactly understand what are you trying to
say. Could you please be bit more specific on what you are trying to
say?
Due to the nature of server side includes being processed before the asp
is processed, you can't use this kind of conditional server side includes.

He shows that the page loads both includes first, and then the server
executes the ASP.

Have a look at this:http://www.4guysfromrolla.com/webtech/022504-1.shtml

Steve

OK....fine.....I got it. The bottomline is ALL include files will be
processed (before any ASP code in the ASP page with the includes is
executed) & included in the ASP page irrespective of whether the
include files have been included conditionally or not. Depending on
the If.....Else condition, the appropriate output will be spat out.

Correct?
Correct :)

Steve
Dec 18 '07 #11

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

6 posts views Thread by Nathan Sokalski | last post: by
9 posts views Thread by Grim Reaper | last post: by
14 posts views Thread by Developer | last post: by
reply views Thread by zhoujie | last post: by
1 post views Thread by Geralt96 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.