Question

Passing variables between ASP Include files

Asked by: jen4950

I am trying to make my site easier to maintain, and want to use include files. The idea here is have each segment of code in an include file, and select what page it is for navigation etc. with a simple index number. I have the sitemap in a spreadsheet that exports the case function in ASP, so updating the site will be a breeze.
So how do I get the passing of that variable between these different navX.asp pages to make this concept work?

As you can see, the main page becomes very easy to maintain- Navigation, nav-crumbs across the top, page titles, links etc. are all maintained in my spreadsheet and called with 1 number. This page works fine when it is all put together in one file.. -> http://vacorp.com/common/demo1.asp

I posted the question in the [H]ardforum- been a member there a long time, you can see the post there : http://www.hardforum.com/showthread.php?p=1032603666#post1032603666 -the formatting makes it easier to digest.

Main Page:
[CODE]
<!--#include virtual="/common/nav1.asp"-->
 
NavIndex = 7
 
<!--#include virtual="/common/nav2.asp"-->
<!--#include virtual="/common/body1.asp"-->
<!--#include virtual="/common/body2.asp"-->
        	
<div id="mainContent">
           <h1> Main Content </h1>
                <p>Lorem ipsum dolor sit amet, consectetuer adipiscing elit.</p>
                <p>Quisque ornare risus quis  ligula.< /p>
            <h2>H2 level heading </h2>
                <p>Lorem ipsum dolor amet, consectetuer adipiscing elit.</p>
</div>
            
<!--#include virtual="/common/body3.asp"-->
[/CODE]
 
nav1.asp:
[CODE]<%
DIM siteMapLocation, sideNavIndex, NavIndex, topLinks, currentDate
[/CODE]
 
nav2.asp (truncated the CASE options for brevity, there are about 30 options):
[CODE]currentDate = FormatDateTime(date(), 1)
currentTime = FormatDateTime(now(), 3)
 
 
SELECT CASE NavIndex
	CASE 1
	topLinks = "<a href=""/index.asp"">Home</a>"
	sideNavIndex="n01"
	CASE 2
	topLinks = "<a href=""/index.asp"">Home</a> > <a href=""/CS/index.asp"">Customer Service</a>"
	sideNavIndex="n09"
	CASE 3
	topLinks = "<a href=""/index.asp"">Home</a> > <a href=""/CS/index.asp"">Customer Service</a> > <a href=""/CS/Individuals/index.asp"">Individuals</a>"
	sideNavIndex="n09"
	CASE 4
	topLinks = "<a href=""/index.asp"">Home</a> > <a href=""/CS/index.asp"">Customer Service</a> > <a href=""/CS/Dealers/index.asp"">Dealers</a>"
	sideNavIndex="n09"
END Select %>
[/CODE]
 
body1.asp (HTML Header information):
 
[CODE]
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> 
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
 
	<head>
		<title>Vehicle Acceptance Corporation - VACorp.com</title>
		<link rel="stylesheet" type="text/css" href="../screenstyles.css" media="screen"/>
        	<link rel="stylesheet" type="text/css" href="../printstyles.css" media="print"/>
        
		<script type="text/javascript" src="../jquery.js"></script>
		<script type="text/javascript" src="../sliding.js"></script>
        <script type="text/javascript" src="../bookmark.js"></script>
        <script type="text/javascript" src="../date.js"></script>
        
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />        
[/CODE]
 
body2.asp (side navigation, images, some CSS styling for the side navigation):
 
[CODE]
		<style type="text/css" media="screen">	
			div#bottomLocation {position:relative; left: 0em; top:8em; height:4em; Z-INDEX: 10;}
			ul#sideNavList li.navLink div.<%response.Write(sideNavIndex)%> a {color:#FF0000;}
	        	ul#sideNavList li.navLink div.<%response.Write(sideNavIndex)%> a:hover {color:#FF0000;} 
			ul#sideNavList li.navLink div.<%response.Write(sideNavIndex)%> a span.{color:#FF0000;}
			ul#sideNavList li.navLink div.<%response.Write(sideNavIndex)%> a span.current{color:#FF0000;}
	        	ul#sideNavList li.navLink div.<%response.Write(sideNavIndex)%> a:hover span.current {color:#FF0000;}
		</style>
        
        <style type="text/css" media="print">
			div#bottomLocation {position:relative; left: 0em; top:8em; height:4em; Z-INDEX: 10;}
			ul#sideNavList li.navLink div.<%response.Write(sideNavIndex)%> a {color:#FF0000; background-color:#FFCC33; font-weight:bold;}
	        	ul#sideNavList li.navLink div.<%response.Write(sideNavIndex)%> a:hover {color:#FF0000; font-weight:bold;} 
			ul#sideNavList li.navLink div.<%response.Write(sideNavIndex)%> a span.{color:#FF0000;}
			ul#sideNavList li.navLink div.<%response.Write(sideNavIndex)%> a span.current{color:#FF0000;}
	        	ul#sideNavList li.navLink div.<%response.Write(sideNavIndex)%> a:hover span.current {color:#FF0000;}
		</style>
        
        
	</head>
	<body class="bodyStyle">
    <div id="headerContainer"> 
        	<div class="Logo"><img src="/images/Common/VACLogo_Web.gif" alt="" width="188" height="150" /></div>
            <div class="LogoTail"><img src="/images/Common/VACLogo_WebTail.gif" alt="" width="100%" height="150"/></div>
            <div class="GradientTop"><img src="/images/Common/Gradient_top.jpg" alt="" width="100%" height="180"/></div>
            <div class="VAC"><img src="/images/Common/VAC.gif" alt="Vehicle Acceptance Corporation"/></div>
        	<div class="VACPrint"><img src="/images/Common/VACTopPrint.jpg" alt="Vehicle Acceptance Corporation" width="750"/></div>
            <div class="VACMotto"><img src="/images/Common/CashandServiceSolutions.gif" alt="" width="300" height="47" /></div>
        </div>
        
    	<div class="GreyNavBar"><div class="topNav"><span class="topNavTimestamp"><%response.Write(currentDate)%> - <%response.Write(currentTime)%> - </span><a onClick="window.print()" href="#">Print</a> - <a href="../EMailPage.asp" target="_blank">E-Mail this page</a> - Navigation: 
      <%response.Write(topLinks)%></div>
    </div>
        
<div id="bodyContainer">
            
            <div id="sideNavBlock">
              <ul id="sideNavList">
                    <li class="navLink"><div class="n00"><a>HOME</a></div></li> 
                    <li class="navTitle">For Customers</li>
                    <li class="navLink"><div class="n01"><a href="/contact/index.htm">Update Your Information<span>Provide VAC updates to your current contact or vehicle information.</span></a></div></li>
                    <li class="navLink"><div class="n02"><a href="/payment/index.htm">Make Your Payment<span><img src="file:///E|/Users/jneubauer/Documents/Websites/Vehicleacceptance.com/Current_VAC_Website/Website_05012008/images/common/CC_Small.gif" alt="Visa, Mastercard, AMerican Express, Discover Credit and Debit Cards Accepted" width="70%" height="70%"/>Arrange payments via online ACH, Online Credit or Debit Cards, Pay-By-Phone or Western Union</span></a></div></li>
                    <li class="navLink"><div class="n03"><a href="/payment/index.htm">Request Your Payoff<span>Request the current amount due to payoff your note</span></a></div></li>
                    <li class="navTitle">For Businesses</li>
                    <li class="navLink"><div class="n04"><a href="/repair/index.htm">Repair Industry Services<span>Find out how VAC can help your repair business convert economically challenged traffic into sales</span></a></div></li>
                    <li class="navLink"><div class="n05"><a href="/advance/index.htm">BHPH Cash Advance<span>Independent businesses receive an advance of 3 to 9 months of payments on your notes, while retaining ownership</span></a></div></li>
                    <li class="navLink"><div class="n06"><a href="/servicing/index.htm">BHPH Note Servicing<span>Independent dealers retain ownership of your receivables while allowing us to collect payments and service your contract for you.</span></a></div></li>
                    <li class="navLink"><div class="n07"><a href="/purchasing/index.htm">BHPH Bulk Purchasing<span>Learn more about our bulk note purchasing program</span></a></div></li>
                    <li class="navTitle">For Everyone</li>
                    <li class="navLink"><div class="n08"><a href="/contact/index.htm">Customer Service</a></div></li>
                    <li class="navLink"><div class="n09"><a href="/locations/index.htm">Locations</a></div></li>
                    <li class="navLink"><div class="n10"><a href="/locations/index.htm">VAC News</a></div></li>
                    <li class="navLink"><div class="n11"><a href="/online/index.htm">Online Solutions</a></div></li>
                    <li class="navLink"><div class="n12"><a href="/about/index.htm">About Us</a></div></li>
                    <li class="navTitle">Interactive</li>
                    <li class="navLink"><div class="n13"><a href="/locations.htm">Login</a></div></li>
                </ul>
            </div>
        [/CODE]
 
body3.asp (bottom feedback form, links etc. end of HTML) :
 
[CODE]
            <!-- Bottom set of navigation options, disclaimer, etc.. -->
                        
...
 
            <!-- END OF Bottom Navigation Set -->
            </div>	
		</div>       
</body>
</html>[/CODE]
                                  
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
66:
67:
68:
69:
70:
71:
72:
73:
74:
75:
76:
77:
78:
79:
80:
81:
82:
83:
84:
85:
86:
87:
88:
89:
90:
91:
92:
93:
94:
95:
96:
97:
98:
99:
100:
101:
102:
103:
104:
105:
106:
107:
108:
109:
110:
111:
112:
113:
114:
115:
116:
117:
118:
119:
120:
121:
122:
123:
124:
125:
126:
127:
128:
129:
130:
131:
132:
133:
134:
135:
136:
137:
138:
139:
140:
141:

Select allOpen in new window

This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.

Subscribe now for full access to Experts Exchange and get

Instant Access to this Solution

  • Plus...
  • 30 Day FREE access, no risk, no obligation
  • Collaborate with the world's top tech experts
  • Unlimited access to our exclusive solution database
  • Never be left without tech help again

Subscribe Now

Asked On
2008-06-11 at 19:37:19ID23478173
Tags

ASP

,

All

,

http://vacorp.com/common/demo1.asp

Topics

Server Side Includes (SSI)

,

Active Server Pages (ASP)

,

Miscellaneous Web Development

Participating Experts
2
Points
250
Comments
9

Trusted by hundreds of thousands everyday for fast, accurate and reliable tech support.

  • "The time we save is the biggest benefit of Experts Exchange to Warner Bros. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange." Mike Kapnisakis, Warner Bros.
  • "Our team likes having a resource that is more secure than just using Google and most experts using this service really know their stuff. It's nice to look here first versus using Google." Dayna Sellner, Lockheed Martin
  • "Anytime that I've been stumped with a problem, 9 out of 10 times Experts Exchange has either the accepted solution or an open discussion of the potential solution to the problem." Kenny Red, eBay Inc.

See what Experts Exchange can do for you.

Got a question?

We've got the answer.

Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.

Screenshot of Experts Exchange Knowledgebase

Need individual assistance?

Our experts are ready to help.

If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.

Screenshot of Experts Exchange Knowledgebase

Want to learn from the best?

Read articles from industry experts.

Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.

Screenshot of an Article

Working on a long term project?

Store your work and research.

Save solutions to your questions, answers you’ve discovered through searching plus helpful articles in your personal knowledgebase for easy future access.

Screenshot of Experts Exchange Knowledgebase

Access the answers to your technology questions today.

Subscribe Now

30-day free trial. Register in 60 seconds.

What Makes Experts Exchange Unique?

Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Trusted by the world's most respected brands.

image of each brand's logo

Faithfully serving IT professionals since 1996.

Experts Exchange Logo

Try it out and discover for yourself.

Subscribe Now

30-day free trial. Register in 60 seconds.

Related Solutions

  1. Concept of ASP
    What is the basic concept of ASP and it's coding syntax likes?example pls.
  2. concept for currency converter
    Can anyone tell me the concept how to do a currency converter in asp and i need it has to be updated everyday automatically depending upon the exchange rates. thank you theresa
  3. Flash nav generator
    I'm building a flash navigation with 8 main nav buttons and a sub nav for each of those 8 main nav buttons and want users to be able to name the main nav and sub nav areas and add as many sub navigation areas as they want. Does anyone know how I can do it the same way that t...
  4. Google Sitemaps
    I am trying to increase traffic at my site www.n2trailhiking.com and was told to try this free sitemap program for Google bots: http://www.iteam5.net/francesco/sitemap_gen/ I placed the asp file in my root directory (and by root I take it to mean www.n2trailhiking.com/sitem...
  5. SiteMap Problem
    Hi, I'm using 6 diff sitemaps on 6 treeviews, however when i load the page, the 6 treeviews will display the first sitemap SiteMapDataSource1 and not its respective sitemap. Any idea? web.config: <siteMap defaultProvider="SiteMapDataSource1"> <provid...
  6. How do I use more than one sitemaps on the same ASPX p…
    I have two separate sitemaps: nav1.sitemap and nav2.sitemap. How do I use them on the same page? In my web.config I have them named like this: <siteMap defaultProvider="XmlSiteMapProvider1" enabled="true"> <providers> <add...

Free Tech Articles

  1. WARNING: 5 Reasons why you should NEVER fix a computer for free.
    It is in our nature to love the puzzle. We are obsessed. The lot of us. We love puzzles. We love the challenge. We thrive on finding the answer. We hate disarray. It bothers us deep in our soul. W...
  2. SCCM OSD Basic troubleshooting
    SCCM 2007 OSD is a fantastic way to deploy operating systems, however, like most things SCCM issues can sometimes be difficult to resolve due to the sheer volume of logs to sift through and the dispe...
  3. Migrate Small Business Server 2003 to Exchange 2010 and Windows 2008 R2
    This guide is intended to provide step by step instructions on how to migrate from Small Business Server 2003 to Windows 2008 R2 with Exchange 2010. For this migration to work you will need the fo...
  4. Create a Win7 Gadget
    This article shows you how to create a simple "Gadget" -- a sort of mini-application supported by Windows 7 and Vista. Gadgets can be dropped anywhere on the desktop to provide instant information, ...
  5. Outlook continually prompting for username and password
    There have been a lot of questions recently regarding Outlook prompting for a username and password whilst using Exchange 2007. There are a few reasons why this would happen and I will try to cover t...
  6. Backup Exchange 2010 Information Store using Windows Backup
    There seems to be quite a lot of confusion around the ability to backup Exchange 2010 using the built in Windows Backup feature. This stems from the omission of this feature prior to Exchange 2007 s...

Cloud Class Webinars

  1. Avoiding Bugs in Microsoft Access
    Alison Balter takes and in-depth look at avoiding bugs in Access. In this webinar you will learn about using the immediate window to debug your applications, invoking the debugger, using breakpoints to troubleshoot, stepping through code, setting the next statement to execute, ...
  2. Top 10 Best New Features in Visio 2010
    Scott Helmers gives live demonstrations of the top 10 new features in Visio 2010. This webinar will teach you how to create compelling diagrams by adding shapes to the page with a single click, linking the shapes in a diagram to data in Excel (or SQL Server, or SharePoint), ...
  3. IT Consultant Business Secrets Revealed
    Michael Munger, Experts Exchange tech pro and IT consultant, pulls back the curtain on his very successful businesses and answers question on every IT consultant and business owner should know about. He shares secrets on what he did to solve the 5 most common problems in IT, ...
  4. Disaster Recovery and Business Continuity
    Quest CTO, Mike Billon, gives an overview of the steps involved in building a dunamic disaster recovery plan. Through case studies and an examination of software/hardware tooles for monitoring and testing, you'll gain a better understandin of where you are, where you want ...
  5. Organize Your Visio Diagrams with Containers and Lists
    Scott Helmers uses cross functional flowcharts, wireframe diagrams, data graphic legends and seating charts to teach you: how to ustilize all three new structured diagram components in Visio 2010, the best practices for organizeing shapes in previous version of Visio, how to organize ...
  6. How to Us Objects, Properties, Events and Methods in Microsoft Access
    Alison Dalter gives an in-depbth look at objects, properties, events and methods in Microsoft Access. In this webinar you will learn about using the object browser, referring to objects, working with properties and methods, working with object variables, understanding the ...

Join the Community

Give a Little. Get a Lot.

Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.

Join the Community

Answers

 

by: dosthPosted on 2008-06-12 at 00:27:27ID: 21766874

declare all variables in global.asa file

 

by: _Stilgar_Posted on 2008-06-12 at 00:32:57ID: 21766900

Or use Session variables, or just declare a variable in the head of your page, and reference it in the include files (for this you will have to make sure it is declared before each file including those files).

Stilgar.

 

by: jen4950Posted on 2008-06-12 at 07:40:44ID: 21769955

So can I declare a session variable in the nav1.asp, and have it utilized in nav2.asp, body1,asp etc?

 

by: dosthPosted on 2008-06-12 at 07:52:26ID: 21770089

yes, the session variable needs to be in the top leve page so you can call it any page

 

by: jen4950Posted on 2008-06-12 at 08:55:55ID: 21770834

Sorry for being a noob here, but is this what the global.asa file would look like? And what happens when a user has cookies disabled? Is an application variable a better solution? And finally, how do I call the variable in my include files, where typically is would be: "SELECT CASE NavIndex" or "<%response.Write(sideNavIndex)%>"

<SCRIPT LANGUAGE="VBScript" RUNAT="Server"> 
 
Sub Application_OnStart 
 
application("activevisitors")=0 
 
End Sub 
 
Sub Application_OnEnd 
End Sub 
 
Sub Session_OnStart 
application.lock 
application("activevisitors")=application("activevisitors")+1 
application.unlock
 
session("siteMapLocation")=""
session("sideNavIndex")=""
session("NavIndex")=""
session("topLinks")=""
session("currentDate")=""
session("currentTime")=""
 
End Sub 
 
Sub Session_OnEnd 
application.lock 
application("activevisitors")=application("activevisitors")-1 
application.unlock 
End Sub 
 
</SCRIPT>
                                              
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:

Select allOpen in new window

 

by: dosthPosted on 2008-06-12 at 09:06:45ID: 21770961

yes global.asa look like this only.

session will work

<%response.Write(session("NavIndex"))%>

 

by: jen4950Posted on 2008-06-12 at 09:13:17ID: 21771012

Last question- do I have to worry about functionality if the user has cookies disabled?

Thanks so much for your help!

 

by: dosthPosted on 2008-06-12 at 09:21:56ID: 21771097

no, session is server side

 

by: jen4950Posted on 2008-06-12 at 09:22:41ID: 21771104

Excellent, Thank you so much!

20120131-EE-VQP-002

3 Ways to Join

30-Day Free Trial

The Experts

98% positive feedback on 31,087 answers since March 2000. angeliii is a Microsoft Most Valuable Professional for his work with MS SQL Server & Develoment.

He has also proven his knowledge of Visual Basic Programming, PHP Scripting and Oracle Databases.

The Experts

97% positive feedback on 10,752 answers since July 2000. lrmoore has more than 18 years experience in the networking industry.

The six-time Mircosoft MVPs specialties include firewalls, virtual private networking, and network management.

Testimonials

"...and excellent source for support... Kind of like having your very own IT dept." Electriciansnet

Testimonials

"I was apprehensive at signing up at first. However... it has already made my life as an IT administrator much easier." JaCrews

Testimonials

"WOW! You guys have great, active, and knowledgeable people on here." moore50

Business Clients

Business Clients

In the Press

"If you’ve got a question... Experts Exchange can supply an answer.”

In the Press

"...an invaluable aid for both IT professionals and those who require tech support."

In the Press

"where IT professionals provide quick answers on just about any topic"

Business Account Plans

Loading Advertisement...