choosing an include file

M

middletree

I have a page which, according to the boss's instructions, needs to show one
of two things, based on which radio button was chosen on the previous page.
Because these 'things' are actually some chunks of code which contain sql
queries, loops, etc., I think it might be best to put each of them into an
include.

Will this work:

<%If strReports = "Detailed" then%>
<!-- #INCLUDE FILE="builddetailedreport.asp" -->
<%Else%>
<!-- #INCLUDE FILE="buildsummary.asp" -->
<%End if%>


Or would it be better to do a response.write?


<%If strReports = "Detailed" then
Response.write "<!-- #INCLUDE FILE='builddetailedreport.asp'--> "
Else
Response.write "<!-- #INCLUDE FILE='buildsummary.asp' --> "
End if%>
 
R

Ray at

middletree said:
I have a page which, according to the boss's instructions, needs to show one
of two things, based on which radio button was chosen on the previous page.
Because these 'things' are actually some chunks of code which contain sql
queries, loops, etc., I think it might be best to put each of them into an
include.

Will this work:

<%If strReports = "Detailed" then%>
<!-- #INCLUDE FILE="builddetailedreport.asp" -->
<%Else%>
<!-- #INCLUDE FILE="buildsummary.asp" -->
<%End if%>


This will work. Both files will be included, but only the code in the one
that is in the true condition will be executed.
Example:
include1.asp:
<% Response.Write "I'm included." %>
include2.asp:
<% Response.Write "I'm included, but not executed." %>

page.asp:
<% If 1 = 1 Then %>
<!-- #include file="include1.asp" -->
<% Else %>
<!-- #include file="include2.asp" -->
<% End If %>

That would be the same as:
<% If 1 = 1 Then %>
<% Response.Write "I'm included." %>
<% Else %>
<% Response.Write "I'm inlcluded, but not executed." %>
<% End If %>


Or would it be better to do a response.write?
<%If strReports = "Detailed" then
Response.write "<!-- #INCLUDE FILE='builddetailedreport.asp'--> "
Else
Response.write "<!-- #INCLUDE FILE='buildsummary.asp' --> "
End if%>

This will not work. All that would do is create a comment in your html
output. Include directives aren't part of the response, and they are
processed before any asp is.

Ray at work
 
C

Chris Hohmann

middletree said:
I have a page which, according to the boss's instructions, needs to show one
of two things, based on which radio button was chosen on the previous page.
Because these 'things' are actually some chunks of code which contain sql
queries, loops, etc., I think it might be best to put each of them into an
include.

Will this work:

<%If strReports = "Detailed" then%>
<!-- #INCLUDE FILE="builddetailedreport.asp" -->
<%Else%>
<!-- #INCLUDE FILE="buildsummary.asp" -->
<%End if%>


Or would it be better to do a response.write?


<%If strReports = "Detailed" then
Response.write "<!-- #INCLUDE FILE='builddetailedreport.asp'--> "
Else
Response.write "<!-- #INCLUDE FILE='buildsummary.asp' --> "
End if%>

I would go with the first one since the second one simply prints out the
include directive. ;-p

-Chris Hohmann
 

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,139
Messages
2,570,805
Members
47,356
Latest member
Tommyhotly

Latest Threads

Top