Wrox Programmer Forums
|
ASP Pro Code Clinic As of Oct 5, 2005, this forum is now locked. No posts have been deleted. Please use "Classic ASP Professional" at: http://p2p.wrox.com/forum.asp?FORUM_ID=56 for discussions similar to the old ASP Pro Code Clinic or one of the other many remaining ASP and ASP.NET forums here.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP Pro Code Clinic section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old May 13th, 2005, 02:03 AM
Authorized User
 
Join Date: Aug 2003
Posts: 52
Thanks: 0
Thanked 0 Times in 0 Posts
Default Conditional Includes

In all asp books it is mentioned that ASP does not have conditional includes. But i wrote a very simple code and could not relate the theory with the results i got. Here is my code:

Code:

<%

'BEGIN Code "inc.asp"       

    dim var
    var=21
    if var<20 then

%>

<%
    else
%>

<%
    end if

'END code inc.asp

'BEGIN CODE "inc1.asp"

        Response.write "Inside inc1.asp"

'END CODE "inc1.asp

'BEGIN CODE "inc2.asp""

        Response.write "Inside inc2.asp"

'END CODE "inc2.asp"

%>
When i run "inc.asp", the result i get is "Inside inc2.asp"
and when i reverse the condition then i get "Inside inc1.asp"

Morever if we go by theory then the include directives are processed earlier than the ASP code, hence both the files should be included prior and should diplay both the lines.

This is a fundamental question. Please clarify.


Thanks in advance.

Vinay
 
Old May 13th, 2005, 08:14 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 1,212
Thanks: 0
Thanked 1 Time in 1 Post
Default

Both lots of code get included, but only the one that passes the test actually gets executed.
 
Old May 13th, 2005, 06:39 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 2,480
Thanks: 0
Thanked 1 Time in 1 Post
Default

Leo_vinay,

Take a look at this post too(both the pages) for better understanding. This might help.

Include Files


Cheers!

_________________________
- Vijay G
Strive for Perfection





Similar Threads
Thread Thread Starter Forum Replies Last Post
ASP Includes in .NET sabu21s Classic ASP Databases 0 October 20th, 2005 04:43 PM
SSI includes in XSLT nrane26 XSLT 1 January 7th, 2005 04:51 AM
J2EE 1.4 says that it includes J2SE ScreamingMinaret J2EE 1 January 27th, 2004 05:03 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.