ASP.NET 2.0 Master Page Problem

Having problems with DHTML Menu? There is usually somebody here who knows the answer.
Post Reply
gelid
Advanced
Advanced
Posts: 11
Joined: Fri Dec 30, 2005 3:53 pm

ASP.NET 2.0 Master Page Problem

Post by gelid »

I am using the menu in an ASP.NET Master Page which is inherited by several other pages. Sometimes the menu displays and sometimes it does not. I dynamically set the menu location and other variables on the master page based on what child page is inheriting the master page.

Below is an example of the master page menu references.

<script id="Script1" language="JavaScript" src='<%=HomeDirectory%>Library/Menu/SETTINGS.js'></script>
<script language="JavaScript" src="<%=HomeDirectory %>Library/Menu/milonic_src.js" type="text/javascript"></script>
<script language="JavaScript">
if(ns4)_d.write("<scr"+"ipt language=JavaScript src=<%=HomeDirectory %>Library/Menu/mmenuns4.js><\/scr"+"ipt>");
else _d.write("<scr"+"ipt language=JavaScript src=<%=HomeDirectory %>Library/Menu/mmenudom.js><\/scr"+"ipt>");
</script>
<script src="<%=MenuSource %>" type="text/javascript"></script>
<script type="text/javascript">drawMenus();</script>

The source on the page shows that the menu items were written to the page correctly. Also, if I have a page that initially displays a criteria form to the user that is used to allow DB searching, the menu initially does not show up. But when the user submits the search, the results are displayed and the menu appears.

I am at a loss on this one. Has anyone else experienced this issue? Any incite would be greatly appreciated.
phatmike11
Beginner
Beginner
Posts: 1
Joined: Thu Feb 02, 2006 7:04 pm
Location: USA
Contact:

Asp.net 2.0 Master Page Sub folder Relative URL error

Post by phatmike11 »

I am having a similar problem. I was running to issues with the images on the page not working under sub folders. I then changed all the images on the page to <asp:image ~/images/imageName.gif>. THat fixed my image problem. Now when the page is rendered it converts the ~ into .. or ../.. However, I have not found a fix for the javascript! Any suggestions? I have tried putting the ~/ into front of the mmenuns4.js file but that only works for server side stuff. If you try and make the script server side it buggers out. I am sure the answer lies in some processing in the codebehind or something, but have to have found a good answer.


<script type="text/javascript" src='milonic_src.js'></script><noscript><div style="width: 655px;"><center>Javascript is disabled, please enable it.</center></div></noscript>
<script type="text/javascript">
if(ns4)_d.write("<scr"+"ipt type=text/javascript src=mmenuns4.js><\/scr"+"ipt>");
else _d.write("<scr"+"ipt type=text/javascript src=mmenudom.js><\/scr"+"ipt>");
</script>
<script type="text/javascript" src="menu_data.js">function IMG1_onclick() { }
</script>
ddudley3
Beginner
Beginner
Posts: 2
Joined: Thu Aug 17, 2006 5:27 am

Has anyone resolved this problem?

Post by ddudley3 »

I am experiencing a similar problem adding the menu to the ASP.NET for VS Web Developer Express.

Has anyone come up with a resolution to this?
DavidD
User avatar
Andy
Milonic
Milonic
Posts: 3308
Joined: Sun May 19, 2002 8:23 pm
Location: Menu Developer
Contact:

Post by Andy »

Do you have any URL's that we can see where the problem exists?
ddudley3
Beginner
Beginner
Posts: 2
Joined: Thu Aug 17, 2006 5:27 am

Post by ddudley3 »

No. I was doing this on my laptop before I copied it to my website.

I ended up using a javascript CSS menu .. But I'm not entirely thrilled with it.


However here is the Master Page ASPX Code:
-------------------------------------------------------------------------------
<%@ Master Language="VB" CodeFile="Default.master.vb" Inherits="Default_master" %>

<!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" xml:lang="en" >
<head runat="server">
<title>My Website</title>
</head>
<body>
<form id="form1" runat="server">
<div class="header" style="left: 0px; top: 0px; height: 49px;">
<h1 style="font-family: 'Arial Narrow'; left: 16px; top: 0px; font-size: 16pt;">
MY WEBSITE</h1>
<h2 style="left: 15px; top: 25px; font-family: 'Arial Narrow'; font-size: 14pt; width: 259px;">
"the place to be"</h2>
<br />
<br />
<br />
<br />
<br />
<br />

<!-- ***** This is the section of code you need to paste into your web pages ***** -->
<script type='text/javascript'>

//HV Menu- by Ger Versluis (http://www.burmees.nl/)
//Submitted to Dynamic Drive (http://www.dynamicdrive.com)
//Visit http://www.dynamicdrive.com for this script and more

function Go(){return}

</script>
<script type='text/javascript' src='exmplmenu_var.js'></script>
<script type='text/javascript' src='menu_com.js'></script>
<noscript>Your browser does not support script</noscript>
<!-- **** JavaScript Menu HTML Code -->

</div>

<asp:contentplaceholder id="Main" runat="server" />

<div class="footerbg">
<div class="footer" style="font-family: 'Arial Rounded MT Bold'">
&nbsp;This is my footer area
</div>
</div>

<asp:sitemapdatasource id="SiteMapDataSource1" runat="server" startingnodeoffset="0" />

</form>

</body>
</html>

-------------------------------------------------------------------------------

And I used the js files that came with the files.
DavidD
User avatar
Andy
Milonic
Milonic
Posts: 3308
Joined: Sun May 19, 2002 8:23 pm
Location: Menu Developer
Contact:

Post by Andy »

Hi,

We really are going to need to see URL's so that we can test them.

Will this be possible?

Cheers,
Andy
User avatar
Andy
Milonic
Milonic
Posts: 3308
Joined: Sun May 19, 2002 8:23 pm
Location: Menu Developer
Contact:

Post by Andy »

Apparently, here is what you need to do:
ASP.NET 2.0 master pages
Message: I was working on a problem with your menu when creating new pages in multiple directories that derive from a master page in VS2005 with .net 2.0. I came across a post on your messageboard http://milonic.com/mfa/2006-January/006950.html with a similar problem and thought I would share the solution.

You will need to use ~/ to resolve the src path of the staticly coded script tags, and hard code the path in the dynamicly created script tag. Now the master page can be referenced by any page in the solution and the scripts that drive the menu will show up fine.
Post Reply