Passing variables between ASP Include files

jen4950

[H]F Junkie
Joined
Apr 25, 2001
Messages
11,393
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.

Gibberish courtesy of DW.

Main Page:
Code:
<!--#include virtual="/common/[COLOR="Red"]nav1.asp[/COLOR]"-->

NavIndex = 7

<!--#include virtual="/common/[COLOR="Lime"]nav2.asp[/COLOR]"-->
<!--#include virtual="/common/[COLOR="Yellow"]body1.asp[/COLOR]"-->
<!--#include virtual="/common/[COLOR="DeepSkyBlue"]body2.asp[/COLOR]"-->
        	
<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/[COLOR="sandybrown"]body3.asp[/COLOR]"-->

nav1.asp:
Code:
<%
DIM siteMapLocation, sideNavIndex, NavIndex, topLinks, currentDate

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 %>

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" />

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>

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>

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
 
For those that are interested, I solved this by declaring the variables in the global.asa file.

Global.asa file:

Code:
<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>

And call the variables like so:

Code:
session("NavIndex")
<%Session("NavIndex") = 7 %>
 
Back
Top