Wrox Programmer Forums
| Search | Today's Posts | Mark Forums Read
Classic ASP Basics For beginner programmers starting with "classic" ASP 3, pre-".NET." NOT for ASP.NET 1.0, 1.1, or 2.0
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Classic ASP Basics 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 June 4th, 2004, 01:29 PM
Friend of Wrox
Points: 1,035, Level: 12
Points: 1,035, Level: 12 Points: 1,035, Level: 12 Points: 1,035, Level: 12
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: , , USA.
Posts: 196
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to jmss66
Default Include Files

Can someone please tell me how to code the include files? I have two include files which I want to use one or the other depending on the calling page. The code below does not even include the files in either situation. I displayed the Request("CallingPage") and it was diplaying the calling page as "Trustee". Still it won't include any files. Please tell me what I am doing wrong.

Thanks,
Judy
<%

 If Request("CallingPage") = "" Then

 Else

 End If
 response.write request("callingPage") & "<br>"


%>


 
Old June 4th, 2004, 02:02 PM
Friend of Wrox
 
Join Date: Aug 2003
Location: Halifax, Nova Scotia, Canada.
Posts: 166
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hello jmss66

Is your "callingpage" holding the right variable?

I don't really understand what you are doing here

 If Request("CallingPage") = "" Then

 Else

How are you calling this page, from a link?
I think it should look more like this

if Request.QueryString("CallingPage")="NameofPage" Then

 Else

-----------------------------------------------------------
"Don't follow someone who's not going anywhere" John Mason
 
Old June 4th, 2004, 02:17 PM
Friend of Wrox
 
Join Date: Jun 2003
Location: Copenhagen, , Denmark.
Posts: 440
Thanks: 0
Thanked 0 Times in 0 Posts
Default

First of all... You cannot choose to include one of these files. Both files would be included if the correct syntax was used. The page/document will be processed/scanned for include statements before doing the actual ASP, and therefore you will not get the effect that you are looking for!

The other thing is that the include statement is not ASP, and therefore should be put outside the ASP block. You can actually see the HTML comment 'tags' (), which allow you to write things that are not shown on the page. Put the include statements in the head section instead, knowing that all include statements will be processed.

Hope it helps

Jacob.
 
Old June 4th, 2004, 05:08 PM
Friend of Wrox
 
Join Date: Sep 2003
Location: Minneapolis, MN, USA.
Posts: 171
Thanks: 0
Thanked 1 Time in 1 Post
Default

Jacob. I do conditional includes all the time and it works for me. Jacob is right, however, that the page will process those include statements first so they must both exist where the code says they exist, even if you are just displaying one.

Are you getting an error at all? Is your includes directory inside the directory the document calling it from is located? If not, you would probably get an error saying 'file not found' or something. If the includes path that you have defined is in the root directory you could try...



ALSO...Have you tried renaming those files (e.g. header.inc.asp to headerinc.asp). Maybe something is screwing up due to your naming convention.

Dave
 
Old June 4th, 2004, 05:35 PM
Friend of Wrox
 
Join Date: Jun 2003
Location: Copenhagen, , Denmark.
Posts: 440
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Take a look at this thread. The topic of conditional includes have been discussed several times in this forum.

BTW... If you want to have the include statement inside an ASP block you should have something like this
Code:
%><%
...since it is not ASP.

Jacob.
 
Old June 4th, 2004, 05:53 PM
Friend of Wrox
 
Join Date: Sep 2003
Location: Minneapolis, MN, USA.
Posts: 171
Thanks: 0
Thanked 1 Time in 1 Post
Default

Oops...I didn't notice that jmss66 had no delimiters. I use something like...

<%if Page = "Home" then%>

<%end if%>

and so on. You gotta excuse me, I'm brain dead after a long day.

 
Old June 5th, 2004, 03:50 AM
Friend of Wrox
 
Join Date: Jun 2003
Location: Copenhagen, , Denmark.
Posts: 440
Thanks: 0
Thanked 0 Times in 0 Posts
Default

In the other thread Peter says that every file is in fact included, but the contents of the file is not processed untill the ASP is processed. Therefore if the contents of the file can sit within the if-then-else structure without causeing syntax errors you will probably have no problems, however I can see several drawbacks to this approach; e.g huge load time (loading more than nessesary), limitations on the contents of the include files, lack of readability etc.

However if you are aware of all those things it can probably work as expected. :)

Jacob.
 
Old June 7th, 2004, 10:40 AM
Friend of Wrox
Points: 1,035, Level: 12
Points: 1,035, Level: 12 Points: 1,035, Level: 12 Points: 1,035, Level: 12
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: , , USA.
Posts: 196
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to jmss66
Default

Hi Guys,

Thanks for helping me. Prior to this code. I tried to code it the way you guys suggested :

<% If Request("CallingPage") = "" Then %>

<% Else %>

<% End If %>

Unfortunately I kept getting this error message. That's why I was experimenting on different ways.

Error Type:
Microsoft VBScript compilation (0x800A0411)
Name redefined
/hfrrf/includes/trustee_header.inc.asp, line 19, column 4


This error message is because both header files have the same variable name called "pagename".
The error above can only happen if both include files were getting displayed. Seems like my if..else..end if statement is not working if this is the case. Which is what led me to experiment trying other coding.

Thanks,
Judy


 
Old June 7th, 2004, 11:00 AM
Imar's Avatar
Wrox Author
Points: 70,322, Level: 100
Points: 70,322, Level: 100 Points: 70,322, Level: 100 Points: 70,322, Level: 100
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

I think you should read the thread that Jacob referred you to. You're missing an important concept about includes.

Your If statement works fine, but include files are included before the page gets processed (that is, before Request("CallingPage") has a meaningful value). That means that regardless the value of Request("CallingPage"), *both files will be included*!!

They may not get processed, but they are included. Since type / variable checking is done before the page is processed, you'll get this error.

In short: dynamic includes won't work they way you're expecting. Take a look here for a couple of "work arounds": http://www.4guysfromrolla.com/webtech/080199-1.3.shtml

Cheers,

Imar
---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.
 
Old June 7th, 2004, 02:03 PM
Friend of Wrox
Points: 1,035, Level: 12
Points: 1,035, Level: 12 Points: 1,035, Level: 12 Points: 1,035, Level: 12
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: , , USA.
Posts: 196
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to jmss66
Default

I tried to follow the example in the link Imar sent me using a select statement.

<%
Select case Request("CallingPage")
case Trustee %>
   <!--#Include File="includes/trustee_header.inc.asp"--%>
<% Case else %>
   <!--#Include File="includes/header.inc.asp"--%>
<% End Select %>

I got the error message below:

Error Type:
Microsoft VBScript compilation (0x800A03F6)
Expected 'End'
/hfrrf/admin_BoardMinutes.asp, line 184




I just went ahead and deleted the variable name that was common to both headers on one of the file. After doing this, I did not have anymore problem. Thanks for all your help.

Thanks,
Judy





Similar Threads
Thread Thread Starter Forum Replies Last Post
include files b00gieman Classic ASP Basics 2 September 15th, 2007 10:22 AM
Include files tarang SQL Server 2000 1 July 18th, 2007 03:32 AM
Include files errors ahmedkhadragi C++ Programming 1 December 8th, 2006 08:02 AM





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