Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP General > Server-Side Includes

Reply
Thread Tools

Server-Side Includes

 
 
RN1
Guest
Posts: n/a
 
      12-16-2007
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?
 
Reply With Quote
 
 
 
 
Anthony Jones
Guest
Posts: n/a
 
      12-16-2007

"RN1" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> 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


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
WiFi Hotspot Directory now includes over 12,000 sites including Intl site! Riverwalk Mobile Wireless Networking 0 09-16-2004 02:45 PM
migrating asp to aspl.net: includes? Davݭ ١risson ASP .Net 4 12-30-2003 09:48 PM
Virtual Includes in ASP.NET Steve ASP .Net 1 11-19-2003 06:58 PM
WEBBOT includes and .ASPX Tor Nordahl ASP .Net 0 11-04-2003 09:49 PM
includes in ASP .NET Geraldine ASP .Net 1 10-29-2003 02:06 PM



Advertisments