469,327 Members | 1,219 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

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

Conditional Includes

Hi,

Will this work in asp 3.0:

If True Then
<!-- #include file="test1.asp" -->
Else
<!-- #include file="test2.asp" -->
End If

- Thomas
Jul 19 '05 #1
10 6138
your IF is weird but the premise is correct
--
Curt Christianson
Owner/Lead Developer, DF-Software
www.Darkfalz.com
"Thomas" <th****@corpuslogic.com> wrote in message
news:%2***************@TK2MSFTNGP12.phx.gbl...
Hi,

Will this work in asp 3.0:

If True Then
<!-- #include file="test1.asp" -->
Else
<!-- #include file="test2.asp" -->
End If

- Thomas

Jul 19 '05 #2
Yes and no.
The include files are processed first, so the contents of test1.asp and
test2.asp will be plugged in. Then your if/then will be processed.

Probably a better solution would be to wrap the contents of test1.asp in a
subroutine, and test2.asp in a separate subroutine.

Example.

test1.asp

Sub test1sub()
'code from test1.asp
End Sub

test2.asp

Sub test2sub()
'code from test2.asp
End Sub

page.asp
<!--#include file="test1.asp"-->
<!--#include file="test2.asp"-->

If True then
Call test1sub
else
Call test2sub
"Thomas" <th****@corpuslogic.com> wrote in message
news:%2***************@TK2MSFTNGP12.phx.gbl...
Hi,

Will this work in asp 3.0:

If True Then
<!-- #include file="test1.asp" -->
Else
<!-- #include file="test2.asp" -->
End If

- Thomas

Jul 19 '05 #3
Yes, it will work, assuming you start and end your ASP blocks
correctly -- though probably not in the way you expect. Both files will
be included, but only the one that matches the condition will be used.

"Thomas" <th****@corpuslogic.com> wrote in message
news:#o*************@TK2MSFTNGP12.phx.gbl...
Hi,

Will this work in asp 3.0:

If True Then
<!-- #include file="test1.asp" -->
Else
<!-- #include file="test2.asp" -->
End If

- Thomas

Jul 19 '05 #4
So

if test1.asp contains this line:
response.write "Hello 1"

and if test2.asp contains this line:
response.write "Hello 2"

The result of
If True Then
<!-- #include file="test1.asp" -->
Else
<!-- #include file="test2.asp" -->
End If

will allways be

Hello 1
Hello 2

- Thomas

"TomB" <sh*****@hotmailXXX.com> wrote in message
news:%2***************@TK2MSFTNGP12.phx.gbl... Yes and no.
The include files are processed first, so the contents of test1.asp and
test2.asp will be plugged in. Then your if/then will be processed.

Probably a better solution would be to wrap the contents of test1.asp in a
subroutine, and test2.asp in a separate subroutine.

Example.

test1.asp

Sub test1sub()
'code from test1.asp
End Sub

test2.asp

Sub test2sub()
'code from test2.asp
End Sub

page.asp
<!--#include file="test1.asp"-->
<!--#include file="test2.asp"-->

If True then
Call test1sub
else
Call test2sub
"Thomas" <th****@corpuslogic.com> wrote in message
news:%2***************@TK2MSFTNGP12.phx.gbl...
Hi,

Will this work in asp 3.0:

If True Then
<!-- #include file="test1.asp" -->
Else
<!-- #include file="test2.asp" -->
End If

- Thomas


Jul 19 '05 #5
No. The processor would convert it to
If True Then
response.write "Hello 1"
Else
response.write "Hello 2"
end if

which would result in
Hello 1

So, it basically does what you want (presumably) but you can run into
conflicts.
If test1.asp contains
Dim x
x=1
and test2.asp contains
Dim x
x=2
then you've "redimmed" and will get an error. However, if they are in
subroutines, the scope of x is within the subroutine so you won't have a
conflict.
"Thomas" <th****@corpuslogic.com> wrote in message
news:uc**************@TK2MSFTNGP11.phx.gbl...
So

if test1.asp contains this line:
response.write "Hello 1"

and if test2.asp contains this line:
response.write "Hello 2"

The result of
If True Then
<!-- #include file="test1.asp" -->
Else
<!-- #include file="test2.asp" -->
End If

will allways be

Hello 1
Hello 2

- Thomas

"TomB" <sh*****@hotmailXXX.com> wrote in message
news:%2***************@TK2MSFTNGP12.phx.gbl...
Yes and no.
The include files are processed first, so the contents of test1.asp and
test2.asp will be plugged in. Then your if/then will be processed.

Probably a better solution would be to wrap the contents of test1.asp in

a subroutine, and test2.asp in a separate subroutine.

Example.

test1.asp

Sub test1sub()
'code from test1.asp
End Sub

test2.asp

Sub test2sub()
'code from test2.asp
End Sub

page.asp
<!--#include file="test1.asp"-->
<!--#include file="test2.asp"-->

If True then
Call test1sub
else
Call test2sub
"Thomas" <th****@corpuslogic.com> wrote in message
news:%2***************@TK2MSFTNGP12.phx.gbl...
Hi,

Will this work in asp 3.0:

If True Then
<!-- #include file="test1.asp" -->
Else
<!-- #include file="test2.asp" -->
End If

- Thomas



Jul 19 '05 #6
No the reult will alwasy be

Hello 1

doing

If True Then
<!-- #include file="test1.asp" -->
Else
<!-- #include file="test2.asp" -->
End If

If True Then
response.write "Hello 1"
Else
response.write "Hello 2"
End If

is exactly the same as doing

"Thomas" <th****@corpuslogic.com> wrote in message
news:uc**************@TK2MSFTNGP11.phx.gbl...
So

if test1.asp contains this line:
response.write "Hello 1"

and if test2.asp contains this line:
response.write "Hello 2"

The result of
If True Then
<!-- #include file="test1.asp" -->
Else
<!-- #include file="test2.asp" -->
End If

will allways be

Hello 1
Hello 2

- Thomas

"TomB" <sh*****@hotmailXXX.com> wrote in message
news:%2***************@TK2MSFTNGP12.phx.gbl...
Yes and no.
The include files are processed first, so the contents of test1.asp and
test2.asp will be plugged in. Then your if/then will be processed.

Probably a better solution would be to wrap the contents of test1.asp in

a subroutine, and test2.asp in a separate subroutine.

Example.

test1.asp

Sub test1sub()
'code from test1.asp
End Sub

test2.asp

Sub test2sub()
'code from test2.asp
End Sub

page.asp
<!--#include file="test1.asp"-->
<!--#include file="test2.asp"-->

If True then
Call test1sub
else
Call test2sub
"Thomas" <th****@corpuslogic.com> wrote in message
news:%2***************@TK2MSFTNGP12.phx.gbl...
Hi,

Will this work in asp 3.0:

If True Then
<!-- #include file="test1.asp" -->
Else
<!-- #include file="test2.asp" -->
End If

- Thomas



Jul 19 '05 #7
http://www.aspfaq.com/show.asp?id=2042
"TomB" <sh*****@hotmailXXX.com> wrote in message
news:uM**************@TK2MSFTNGP11.phx.gbl...
No. The processor would convert it to
If True Then
response.write "Hello 1"
Else
response.write "Hello 2"
end if

which would result in
Hello 1

So, it basically does what you want (presumably) but you can run into
conflicts.
If test1.asp contains
Dim x
x=1
and test2.asp contains
Dim x
x=2
then you've "redimmed" and will get an error. However, if they are in
subroutines, the scope of x is within the subroutine so you won't have a
conflict.
"Thomas" <th****@corpuslogic.com> wrote in message
news:uc**************@TK2MSFTNGP11.phx.gbl...
So

if test1.asp contains this line:
response.write "Hello 1"

and if test2.asp contains this line:
response.write "Hello 2"

The result of
> If True Then
> <!-- #include file="test1.asp" -->
> Else
> <!-- #include file="test2.asp" -->
> End If
>
will allways be

Hello 1
Hello 2

- Thomas

"TomB" <sh*****@hotmailXXX.com> wrote in message
news:%2***************@TK2MSFTNGP12.phx.gbl...
Yes and no.
The include files are processed first, so the contents of test1.asp and test2.asp will be plugged in. Then your if/then will be processed.

Probably a better solution would be to wrap the contents of test1.asp
in a subroutine, and test2.asp in a separate subroutine.

Example.

test1.asp

Sub test1sub()
'code from test1.asp
End Sub

test2.asp

Sub test2sub()
'code from test2.asp
End Sub

page.asp
<!--#include file="test1.asp"-->
<!--#include file="test2.asp"-->

If True then
Call test1sub
else
Call test2sub
"Thomas" <th****@corpuslogic.com> wrote in message
news:%2***************@TK2MSFTNGP12.phx.gbl...
> Hi,
>
> Will this work in asp 3.0:
>
> If True Then
> <!-- #include file="test1.asp" -->
> Else
> <!-- #include file="test2.asp" -->
> End If
>
> - Thomas
>
>



Jul 19 '05 #8
in my routines this runs well like:
<%
if Session("logado") <> "sim" then
'Rotina de verificação de sessão do usuário só funciona dentro das
tags<body></body>
%>
<!--#include file="controle_sessao.asp" -->
<%End If%>
bye

--

««««««««»»»»»»»»»»»»»»
Vlmar Brazão de Oliveira
Desenvolvimento Web
HI-TEC
"Thomas" <th****@corpuslogic.com> escreveu na mensagem
news:#o*************@TK2MSFTNGP12.phx.gbl...
Hi,

Will this work in asp 3.0:

If True Then
<!-- #include file="test1.asp" -->
Else
<!-- #include file="test2.asp" -->
End If

- Thomas

Jul 19 '05 #9
On Fri, 16 Jan 2004 13:44:16 -0200, "Vilmar Brazão de Oliveira" <te***@teste.teste.teste> wrote:
in my routines this runs well like:
<%
if Session("logado") <> "sim" then
'Rotina de verificação de sessão do usuário só funciona dentro das
tags<body></body>
%>
<!--#include file="controle_sessao.asp" -->
<%End If%>
bye


What most of the responses want to emphasise is that, even though the logic will work and only the 'correct' page will
be displayed, all of the includes will be read and processed before anything else happens...If those pages are large
and/or contain lots of processor intensive or memory heavy stuff, you can run into real resource depletion problems.

The faq citation from Tom B :
http://www.aspfaq.com/show.asp?id=2042

has, at the end, a discussion of using Server.Execute - It will help, if it can be employed in your situation.

hth

Jul 19 '05 #10

If the content in test1.asp and test2.asp are not dependent on the
rest of the page ... I would consider Server.Execute in your if/then
... that way the entire pages code from the files won't be pulled in
... only what is executed.


On Fri, 16 Jan 2004 09:43:10 -0500, "Thomas" <th****@corpuslogic.com>
wrote:
Hi,

Will this work in asp 3.0:

If True Then
<!-- #include file="test1.asp" -->
Else
<!-- #include file="test2.asp" -->
End If

- Thomas


I participate in the group to help give examples of code. I do not guarantee the effects of any code posted. Test all code before use!

Brynn
www.coolpier.com
Jul 19 '05 #11

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

11 posts views Thread by Steven T. Hatton | last post: by
2 posts views Thread by Wesley | last post: by
10 posts views Thread by Dave | last post: by
36 posts views Thread by anon.asdf | last post: by
1 post views Thread by barcaroller | last post: by
4 posts views Thread by rocketeer | last post: by
reply views Thread by suresh191 | last post: by
reply views Thread by haryvincent176 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.