Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Included ASP page in ASP page Error

Status
Not open for further replies.

mrgulic

Technical User
Sep 18, 2001
248
US
I am trying it get an INCLUDED ASP page to successfully run within another ASP page.

The INCLUDED ASP page is the menu (which I am trying to render dynamically through contents of a database.) Normally the menu ASP is static and changed via FrontPage but the app that I am building requires that menu be static as input from users will change the content of the database and thus the menu.

Previewed separately, they ASP pages work fine (NO errors) however when they are combined and opened is when the cryptic unhelpful error occurs.


(Microsoft VBScript runtime error '800a01a8'
Object required: ''

/dev/kb/default.asp, line 50
)


I can only assume that the action that I am attempting is not valid.


The database is included in the menu.asp file which is in turn included in the default.asp page.

The connection to the database and recodset is controled in the menu.asp file (open, used and closed).

I hope that someone can help.

DEFAULT.ASP
Code:
<html>
<head>
<link REL="stylesheet" HREF="includes/default.css" TYPE="text/css">
<link REL="stylesheet" HREF="includes/hdr_n_nav.css" TYPE="text/css">
<title>Site Home Page Template</title>
</head>

<body>
<table width="100%" cellspacing="0" cellpadding="0">
  <tr>
    <td name="HeaderCell" id="HeaderCell" colspan="3"><a name="Top"></a><!--webbot bot="HTMLMarkup" ALT="&lt;h4&gt;The new Header is in place ...&lt;/h4&gt;" TAG="XBOT" StartSpan -->
<IFRAME scrolling="no" width="100%" height="94" frameborder="0" marginheight="0" src="header.htm"></IFRAME><!--webbot BOT="HTMLMarkup" endspan -->
</td>
  </tr>
  <tr>
    <td width="81%" valign="top" style="border: 0" colspan="2">
    <!--webbot bot="Include" U-include="../../../includes/site_header.htm" TAG="BODY" --></td>
    <td name="RightMarginCell" id="RightMarginCell" width="19%" rowspan="2"><img src="common/images/rightspacer.gif" width="78" hspace="60" height="1"><p><!--webbot bot="PurpleText" PREVIEW="do not modify." --></td>
  </tr>
  <tr>
    <td name="MenuCell" id="MenuCell" valign="top" bgcolor="DDDDDD" style="border: 0">
    <!--webbot bot="Include" U-include="menu.asp" TAG="BODY" --></td>
    <td class="Content" name="ContentCell" id="ContentCell" width="80%" valign="top">

    <h1>Welcome</h1>
    <p class="Keyword">Keyword = Keyword Text</p>
    
    <p>
    Enter Site Content
    </p>
    
    
    </td>
  </tr>
  <tr>
    <td name="FooterCell" id="FooterCell" class="CellColorLighter"></td>
    <td name="Footer" id="Footer" colspan="2">
    <!--webbot bot="Include" U-include="../../../includes/footer.htm" TAG="BODY" --></td>
  </tr>
</table>
</body>
</html>


MENU.ASP
Code:
<!-- #INCLUDE file="includes/adovbs.inc" -->
<!-- #INCLUDE file="includes/db_kb.inc" -->

<%
Dim rstMenu, strSQLMenu
Set rstMenu = Server.CreateObject("ADODB.Recordset")
strSQLMenu = "SELECT DISTINCT tblCatagory.CID, tblCatagory.txt_Catagory_Title" & _
			" FROM (tblCatagory RIGHT JOIN tblSubCatagory ON tblCatagory.CID = tblSubCatagory.[_CID])" & _
			" RIGHT JOIN tblKnowledgebase ON tblSubCatagory.SCID = tblKnowledgebase.[_SCID]" & _
			" ORDER BY tblCatagory.txt_Catagory_Title;"
rstMenu.Open strSQLMenu, adoCon
%>
<html>
<head>
<link REL="stylesheet" HREF="includes/default.css" TYPE="text/css">
<link REL="stylesheet" HREF="includes/hdr_n_nav.css" TYPE="text/css">

<title>Menu Exampletitle>
</head>

<body> 

<table name="Menu" id="Menu" border="0" width="250" cellspacing="0" cellpadding="0">
  <tr class="menuhead">
    <td class="menuheadcell"><a href="default.asp">Site Home</a> </td>
  </tr>
  <tr class="menuhead">
    <td class="menuheadcell"><a href="menulevel1.asp">Menu&nbsp;Level Page</a></td>
  </tr>
<%
		If rstMenu.RecordCount < 0 Then
			rstMenu.MoveFirst			
			Do While Not rstMenu.EOF
%>
  
	  <tr class="menuitem">
	    <td class="menuitemcell">
			<a href="view_catagory.asp?ID=<%=rstMenu.Fields("CID")%>"><%=rstMenu.Fields("txt_Catagory_Title")%></a>
	    </td>
	  </tr>
<%		
				rstMenu.MoveNext
			Loop
		End If	
%>

  <tr class="menuitem">
    <td class="menuitemcell"><a href="menulevel2.asp">Sub-Menu Level Page</a></td>
  </tr>
  <tr class="menuhead">
    <td class="menuheadcell"><a href="sitesearch.htm">Site Search Page</a></td>
  </tr>
</table>
<script language="Javascript" src="scripts/menu.js"></script>
<%
rstMenu.Close
Set rstMenu = Nothing
adoCon.Close
Set adoCon = Nothing
%>
</body>
</html>



db_kb.inc
Code:
<%
Dim adoCon
Dim mydb
	
Set adoCon = Server.CreateObject("ADODB.Connection")
	
mydb = Server.MapPath("/virtual/do/data/database/kb.mdb")
adoCon.ConnectionString ="Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" & mydb
	
adoCon.Open
%>


adovbs.inc is just a standard ADO constants include file for VBScript

Thanks in advance for any help
 
Have you tried replacing the webbot include with a normal ASP include?

 
If by "normal ASP include" you mean

<!--#include file="menu.asp"-->

then, yes, I have tried it. While this does not produce a error it also does not seem to execute the java script which expands the menu to show sub-menu items when the parent item is clicked.

the BODY tag in default.asp should include

<body onload="SetMenu()">

Code:
<!--
function SetMenu()
{

//	All of the string variables below are being passed as regular expressions so they will
//	not have problems when being passed to a search function (which takes regular expressions).

	topMenuItem = false;
	foundHREF = false;
	var sbookmark = /#/;
	var sparmlist = /\?/;
	var sFileExt1 = /\.htm/;
	var sFileExt2 = /\.html/;
	var sFileExt3 = /\.asp/;
	CheckSix = false;
	
	// Change WDB 
	// vars used to handle a URL with a query (?)
	// The whole algorithm to find out which menu item should be highlighted
	// is executed twice; once for the URL with the query, once without
	
	var iNumberOfTries = 1
	var iTries
	
if (document.all.L2)

// L2 is the name of the level 2 breadcrumb "L2" on level 3...n pages. 
// if it exists, match on the breadcrumb url
{
	s = document.all.L2.href;
}

else

// If  L2 does not exist, work with the current url.
{	
	s = document.URL;

	//  Check for bookmark in url, and strip out the bookmark name

	t = s.search(sbookmark);
	if (t != -1)
	{
		s = (s.substring(0,t));
	} 

	//  Check for a parameter in url, and strip out any parmlist

	t = s.search(sparmlist);
	if (t != -1)
	{
		// if there is a query, try twice
		// Once with the query string, once without
		iNumberOfTries = 2
	} 

}
for (iTries=0;iTries<iNumberOfTries;iTries++) 
{
	if (iTries==1) 
	{
		// the second time, strip the query
		t = s.search(sparmlist);
		if (t != -1)
		{
			s = (s.substring(0,t));
		} 
	}
//
//	search the URL for a file extension
//
sURL = s;
FoundFileExt = (sURL.search(sFileExt1) >= 0) || (sURL.search(sFileExt2) >= 0) || (sURL.search(sFileExt3) >= 0);

//
// Create an array of all anchor tags on the page and loop through it to match to the url.
//
	a = document.links;

Outerloop:
	for (i=0;i<a.length;i++) 
	{
//
//	If there is no file extension on the URL then concatenate the six possible auto loading
//	pages to the URL and check if there is a match under the current url in the array.
//
		if (!FoundFileExt)
		{
		CheckSix = (a[i].href.toLowerCase() == (sURL.toLowerCase() + "default.htm")) ||
				   (a[i].href.toLowerCase() == (sURL.toLowerCase() + "default.html")) ||
				   (a[i].href.toLowerCase() == (sURL.toLowerCase() + "default.asp")) ||
				   (a[i].href.toLowerCase() == (sURL.toLowerCase() + "index.htm")) ||
				   (a[i].href.toLowerCase() == (sURL.toLowerCase() + "index.html")) ||
				   (a[i].href.toLowerCase() == (sURL.toLowerCase() + "index.asp"));
		}
		if (a[i].href.toLowerCase() == s.toLowerCase() || CheckSix) 
		{
			j = a[i];
			foundHREF = true;
				
	Innerloop:			
  			for (k=1;k<5;k++)

			{
				j = j.parentElement;
				if (j.tagName == "TR")
				{
					if (j.className == "menuitem") 
					{
						j.className = "menushow";
						j.style.backgroundColor = "white";
						topMenuItem = false;
						break Outerloop;
					}
			 	 else if (j.className == "menuhead")
					{
						j.style.backgroundColor = "white";
						topMenuItem = true;
						break Outerloop;
					}
				}	// this is a table data element	
			}	// inner for loop
		}	// url matches
	}	// outer for loop
	
	
// If no match on href, default the menu to the first top level item, which should be the site home.
// Changed by WDB : only set after the second time in case of a query url
 
if ((!foundHREF && (iNumberOfTries == 1)) || (!foundHREF && (iNumberOfTries == 2) && (iTries == 1) ))

{  // Build an array of all data tags and set the first top level menu item background to white.
	tdTags = document.all.tags("TR");

	for (k=0;k<tdTags.length;k++)
	{
		if (tdTags[k].className == "menuhead")
		{
			tdTags[k].style.backgroundColor = "white"
			topMenuItem = true;
			break;
		}
	}

}

else

{	// Build an array of all data tags for the following logic.

	tdTags = document.all.tags("TR");
}
	
// determine where we left off above (will be represented by k)	
	
for (k=0;k<tdTags.length;k++) 
{
	if (tdTags[k].style.backgroundColor == "white")
	{
		break; 
	}
}	// for loop
	
// if we were inside a menu, let's work backwards and display any other menu section entries

if (!topMenuItem)
{
	for (l=(k-1);l>0;l--)
	{
	if (tdTags[l].className == "menuhead") 
	{
		tdTags[l].style.backgroundColor = "#EEEEEE";					
		break;
	}
	else if (tdTags[l].className == "menuitem") 
		{
			tdTags[l].className = "menushow";
			tdTags[l].style.backgroundColor = "#EEEEEE";
		}
	     else
		{
		// all menu data should be menuitem or menushow -
		// when you hit something else, stop.
		break;		 
		}
	}  // for loop
}  // topMenuItem is false
	
// now let's work forwards - this is the same code whether up above we 
// displayed a menu section head, or a menu section item

for (l=k+1;(l<tdTags.length);l++)
{
	if (tdTags[l].className == "menuhead") 
	{
		break;
	}
  	else if (tdTags[l].className == "menuitem")
	{
		tdTags[l].className = "menushow";
		tdTags[l].style.backgroundColor = "#EEEEEE";					
		topMenuItem = true;
	}
}	// for loop 
} //end of Tries loop

}  // end of function
//-->
 
[...] it also does not seem to execute the java script which expands the menu to show sub-menu items when the parent item is clicked.

Why should it? The click event is a browser-side event but all of the ASP executes on the server and is done running before the page is sent to the browser.


PS: I just noticed that the "include file" named menu.asp has its own <html> and <body> tags.

 
I don't know why it doesn't work but I removed the html, head and body tags from menu.asp, but the java still does not work on click as it does when menu.asp is not "included".

I did not write the original stuff, I am only trying to alter it to meet a different need.

Thanks anyway for your help.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top