Print Page | Close Window

Header Includes Problem

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=7158
Printed Date: 29 March 2026 at 2:07pm
Software Version: Web Wiz Forums 12.08 - https://www.webwizforums.com


Topic: Header Includes Problem
Posted By: twooly
Subject: Header Includes Problem
Date Posted: 11 November 2003 at 7:34am

Ok I am trying to clean up my code now that I have things working ok.  Basicly I am trying to get the html formating out to one include file that way you only have to change one file to change the look.  But for some reason it won't include the file.  Here is my code

If userAdmin = 1 then
<!--#include file='adminheader.inc'-->
Else
<!--#include file='header.inc'-->
End If

 

But if I put the contents of each include into their area then it works.  Anyone have ideas why it doesn't work?

 

Works this way

If userAdmin = 1 then
Response.Write ("<table align='right'><tr><td><a href='main.asp'><img src='images/home2_324.gif' alt='Home' border='0'></a></td><td><a href='profile.asp?mode=view'><img src='images/search_16.gif' alt='View Profile' border='0'></a></td><td><a href='profile.asp?mode=edit'><img src='images/save_16.gif' alt='Edit Profile' border='0'></a></td><td><a href='profile.asp?mode=password'><img src='images/security.gif' alt='Change Password' border='0'></a></td><td><a href='logout.asp'><img src='images/Log-Off_324.gif' alt='Logoff' border='0'></a></td></tr><tr>< td><a href='admin.asp?mode=options'><img src='images/options.gif' alt='Options' border='0'></a></td><td><a href='admin.asp?mode=add'><img src='images/add_account.gif' alt='Add Account' border='0'></a></td><td><a href='admin.asp?mode=admin'><img src='images/add_admin.gif' alt='Add Admin' border='0'></a></td><td><a href='admin.asp?mode=listusers'><img src='images/editaccounts.gif' alt='Edit Accounts' border='0'></a></td><td><a href='admin.asp?mode=reports'><img src='images/reports.gif' alt='Reports' border='0'></a></td></tr></table> <br><br><br><br>")
Else
Response.Write ("<table align='right'><tr><td><a href='main.asp'><img src='images/home2_324.gif' alt='Home' border='0'></a></td><td><a href='profile.asp?mode=view'><img src='images/search_16.gif' alt='View Profile' border='0'></a></td><td><a href='profile.asp?mode=edit'><img src='images/save_16.gif' alt='Edit Profile' border='0'></a></td><td><a href='profile.asp?mode=password'><img src='images/security.gif' alt='Change Password' border='0'></a></td><td><a href='logout.asp'><img src='images/Log-Off_324.gif' alt='Logoff' border='0'></a></td></tr></table> <br><br><br><br>")
End If




Replies:
Posted By: ljamal
Date Posted: 11 November 2003 at 7:47am
<% If userAdmin = 1 then %>
<!--#include file='adminheader.inc'-->
<% Else %>
<!--#include file='header.inc'-->
<% End If %>

The newest versions of ASP disables the ability to do includes within a code block.

-------------
L. Jamal Walton

http://www.ljamal.com/" rel="nofollow - L. Jamal Inc : Web/ Print Design and ASP Programming


Posted By: twooly
Date Posted: 11 November 2003 at 7:54am

Worked like a charm.  I guess that is why I am a newbie.  Thanks for the help.

 

--Todd



Posted By: twooly
Date Posted: 11 November 2003 at 8:08am

Ok along those same lines how can I include DB information?

<%

ASP code here

<!--#include file='dbconnection.inc'--> ??????????

ASP code here

%>

contents of dbconnection.inc

Dim adoCon         'Holds the Database Connection Object

'Create an ADO connection object
Set adoCon = Server.CreateObject("ADODB.Connection")

'Set an active connection to the Connection object using a DSN-less connection
adoCon.Open "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" & Server.MapPath("site.mdb")



Posted By: ljamal
Date Posted: 11 November 2003 at 8:13am
in the same manner
<%

ASP code here

%>
<!--#include file='dbconnection.inc'-->
<%

ASP code here

%>


-------------
L. Jamal Walton

http://www.ljamal.com/" rel="nofollow - L. Jamal Inc : Web/ Print Design and ASP Programming


Posted By: twooly
Date Posted: 11 November 2003 at 9:00am
Here is the problem.  I tried that and when I do that it basicly just prints out the contents of the file.  I just want the file used for the information inside of it not print it.  (Contains DB Conntection information)


Posted By: twooly
Date Posted: 11 November 2003 at 9:06am
Nevermind got it figured out.  I didn't have <% %> in my include file



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