Click to See Complete Forum and Search --> : 'this.menu' is not null or an object


msandlana
April 21st, 2008, 07:56 AM
Hello every I am receiving the above error the page is running but it does not show the stylesheet
here is my code:

<%@ Master Language="VB" CodeFile="login.master.vb" Inherits="Admin_login" %>
<%@ Register Src="Admin/Controls/MainSiteMenu.ascx" TagName="MainSiteMenu" TagPrefix="uc1" %>

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head id="Head1" runat="server">

<title>SMART</title>
<link rel="stylesheet" type="text/css" href="Admin/Design/spurintranet.css" />
<link rel="stylesheet" type="text/css" href="Admin/Design/Menu.css" />
<!--#include virtual="Admin/Controls/MainSiteMenu.js" -->

<script type="text/javascript">
var myMenu;

window.onload = function()
{
myMenu = new SDMenu("my_menu");
myMenu.init();
};
</script>

</head>
<body>
<form id="frmMain" runat="server">
<div id="header"><img runat="server" src="Admin/Design/SiteImages/CIPLogoAdmin.gif" alt="" id="SpurLogo" /></div>
<div id="MainContentPanel">
<h1 class="SectionNameH1">
<asp:SiteMapPath ID="SiteMapPath1" runat="server">
</asp:SiteMapPath></h1>

<div id="MainContent">
<asp:contentplaceholder id="ctnBody" runat="server">
</asp:contentplaceholder>
</div>
</div>

<div id="Footer"></div>

</form>
</body>
</html>

Alsvha
April 21st, 2008, 01:24 PM
Looks like you have a script error somewhere in your JavaScript.
Without additional information - I'd guess that your "my_menu" in the javascript function doesn't map to an object.

But it is a guess because you do not say when or where you get the error from.

msandlana
April 22nd, 2008, 01:27 AM
Here is part of my javascript the error is pointing on this line:this.submenus = this.menu.getElementsByTagName("div");

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head id="_ctl0_Head1"><title>
Careers in pharmacy - login
</title><link rel="stylesheet" type="text/css" href="Admin/Design/spurintranet.css" /><link rel="stylesheet" type="text/css" href="Admin/Design/Menu.css" /><script type="text/javascript">

function SDMenu(id)
{
if (!document.getElementById || !document.getElementsByTagName)
return false;

this.menu = document.getElementById(id);
this.submenus = this.menu.getElementsByTagName("div");
this.remember = true;
this.speed = 3;
this.markCurrent = true;
this.oneSmOnly = true;
}

Alsvha
April 22nd, 2008, 03:25 AM
you need an element called "my_menu" to be able to reference it from JavaScript.

I can't see anywhere that you have such an element, hence the error you get when trying to call "getElementById" on it and using that reference (it returns null when there are no element) later in the code.
So because getElementById returns null, and you then try to get "submenus" from it (by getting all divs), it will crash/throw the error.

Looks to me like you are getting some techniques crossed in your implementation.