Print Page | Close Window

Include help

Printed From: Web Wiz Forums
Category: General Discussion
Forum Name: Classic ASP Discussion
Forum Description: Discussion on Active Server Pages (Classic ASP).
URL: https://forums.webwiz.net/forum_posts.asp?TID=6839
Printed Date: 31 March 2026 at 1:54pm
Software Version: Web Wiz Forums 12.08 - https://www.webwizforums.com


Topic: Include help
Posted By: DaFool
Subject: Include help
Date Posted: 29 October 2003 at 1:42pm
'If the header ad image variable isnt empty, display the image
If strSiteHeaderImage2 <> "" Then
 Response.Write(vbCrLf & "         <td width=""100%"" align=""right"">%><!--#include file="../BannerRotator.asp"--><%</td>")
End If

What's wrong with this file?



Replies:
Posted By: ctscott
Date Posted: 29 October 2003 at 1:57pm

to quote from my visual studio 6.0 documentation:

"You can also use the file keyword with ../ syntax to include a file from a parent, or higher-level, directory if the Enable Parent Paths option is selected in Internet Service Manager."

that may be the problem but i don't know.  you can also try using the "virtual" keyword in place of "file" where you indicate a path beginning with the virtual directory.

 



Posted By: DaFool
Date Posted: 29 October 2003 at 3:08pm
thats not the problem, it has to be something else. Thanks for your reply


Posted By: KCWebMonkey
Date Posted: 29 October 2003 at 4:16pm
the problem is that include files are ran before any other asp code, so you can't put an include file in an if statement.


Posted By: ctscott
Date Posted: 29 October 2003 at 7:10pm
learn something everyday.


Posted By: DaFool
Date Posted: 29 October 2003 at 7:56pm
then how do I need to go about getting this thing to work?


Posted By: fernan82
Date Posted: 29 October 2003 at 8:45pm
The problem was that you closed the <% %> tags without finishing the Response.Write, a simple way would be to do this:

If the header ad image variable isnt empty, display the image
If strSiteHeaderImage2 <> "" Then %>
<td width="100%" align="right"><!--#include file="../BannerRotator.asp"--></td><%
End If

Or this:

If the header ad image variable isnt empty, display the image
If strSiteHeaderImage2 <> "" Then
Response.Write(vbCrLf & "        <td width=""100%"" align=""right"">") %>
<!--#include file="../BannerRotator.asp"-->
<% Response.Write("</td>")
End If

<edit> You can't close the script block unless you're done with the command like you do with html... You had closed the script block right in the middle of the Response.Write, you had to finish it first, then close it, include the file, and start a new response.write... It would just make more sense and perform better to just use HTML instead of Response.Write as in my first example...

-------------
FeRnAN
http://www.danasoft.com/">


Posted By: fernan82
Date Posted: 29 October 2003 at 9:01pm
Originally posted by KCWebMonkey KCWebMonkey wrote:

the problem is that include files are ran before any other asp code, so you can't put an include file in an if statement.


You sure can put it on an If statement, what you can't do is put it inside a Response.Write. In that case the problem was that the script block was closed before closing the response.write...

The includes are not exactly ran before the asp code, many people think that but it's incorrect. The includes just can't be placed inside ASP code cuz they're not ASP and can't be used on Response.Write cuz they're not client side stuff that's why they're called server side includes (Response.Write just sends text to the browser).

As long as it's not inside a script block you can use it anywhere... What you can't do is include the same file or two files with the same variables on the same script cuz the server includes the files before executing any ASP so you'll get a variable redefined error... same as if you do this:

If strHuh = "Hello" Then
     Dim intHuh
     intHuh = 5
Else
     Dim intHuh
     intHuh = 1
End If

Even though the var is only gonna be defined once that would cause a variable redefined error...

-------------
FeRnAN
http://www.danasoft.com/">


Posted By: gupta_ji
Date Posted: 30 October 2003 at 6:53am
thats not the problem, it has to be something else. Thanks for your reply

-------------
http://www.sgrj.com" rel="nofollow - chartered accountants India , http://www.delhiprofessionals.com" rel="nofollow - accounting Outsourcing ISO Certification


Posted By: KCWebMonkey
Date Posted: 30 October 2003 at 7:28am

Originally posted by gupta_ji gupta_ji wrote:

thats not the problem, it has to be something else. Thanks for your reply

well, if you're just going to keep telling us "that's not the problem, what else?" and not try to help with your own problems, then you might as well stop asking for help at all.



Posted By: DaFool
Date Posted: 30 October 2003 at 7:42am
Originally posted by KCWebMonkey KCWebMonkey wrote:

Originally posted by gupta_ji gupta_ji wrote:

thats not the problem, it has to be something else. Thanks for your reply

well, if you're just going to keep telling us "that's not the problem, what else?" and not try to help with your own problems, then you might as well stop asking for help at all.



He just copied what I had posted. I decided to take the IF statement out and do this:

%>
<td width="100%" valign="middle" align="right"><!--#include virtual="BannerRotator.asp"--> </td>
<%


Posted By: KCWebMonkey
Date Posted: 30 October 2003 at 8:47am
that guy is getting on my nerves


Posted By: fernan82
Date Posted: 30 October 2003 at 9:37am
somebody should do something about these trolls...

-------------
FeRnAN
http://www.danasoft.com/">



Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.08 - https://www.webwizforums.com
Copyright ©2001-2026 Web Wiz Ltd. - https://www.webwiz.net