Masterpage e Javascript.

lunedì 25 maggio 2009 - 10.47

iif Profilo | Expert

Ciao, dovrei eseguire del codice javascript all'interno di una masterpage, per chiarezza vi sposto il codice:

<%@ Master Language="VB" CodeFile="MasterPage.master.vb" Inherits="MasterPage" %>
<head runat="server">
<title>Pagina senza titolo</title>
<link rel="stylesheet" href="Cartella/menu.css" />
</head>
<body>
<script type="JavaScript" src="Cartella/menu.js"></script>
<script type="JavaScript" src="Cartella/menu_items.js"></script>
<script type="JavaScript" src="Cartella/menu_tpl.js"></script>
<form id="form1" runat="server">
<div>
<script type="JavaScript">
new menu (MENU_ITEMS, MENU_TPL);
</script>

&nbsp;<br />
<br />
<br />
<br />
<asp:contentplaceholder id="ContentPlaceHolder1" runat="server">
</asp:contentplaceholder>
</div>
</form>
</body>
</html>

Quano la mando in esecuzione non visualizza e non da errore, non capisco cosa manca.

Grazie.

Anonimo Profilo | Senior Member

Puoi postare il javascript? Perchè a primo colpo posso domandardi ma le variabili che passi alla funzione sono valorizzate? Sono delle costanti definite da codice?

iif Profilo | Expert

Lo stesso codice in una pagina html funziona.

Anonimo Profilo | Senior Member

Ok dopo un po' di test funzionanti mi viene da dirti che il problema risiede 99,9% nel codice javascript, controlla che il codice abbia tutti i riferimenti giusti padri figlio e che gli eventuali url siano rispettati.

iif Profilo | Expert

Questo è il codice originale:
<html>
<head>
<title>JavaScript Menu - Demo #1</title>
<!-- styles for demo menu #1-->
<link rel="stylesheet" href="menu.css">
</head>

<body>

<!-- comments begin -->

<!-- comments end -->

<!-- menu script itself. you should not modify this file -->
<script language="JavaScript" src="menu.js"></script>
<!-- items structure. menu hierarchy and links are stored there -->
<script language="JavaScript" src="menu_items.js"></script>
<!-- files with geometry and styles structures -->
<script language="JavaScript" src="menu_tpl.js"></script>
<script language="JavaScript">
<!--//
// Make sure the menu initialization is right above the closing </body> tag
// Moving it inside other tags will not affect the position of the menu on
// the page. If you need this feature please consider Tigra Menu GOLD.

// each menu gets two parameters (see demo files)
// 1. items structure
// 2. geometry structure

new menu (MENU_ITEMS, MENU_TPL);

// If you don't see the menu then check JavaScript console of the browser for the error messages
// "Variable is not defined" error indicates that there's syntax error in that variable's definition
// or the file with that variable isn't properly linked to the HTML document
//-->
</script>

</body>
</html>

Mi sfugge la differenza.

Anonimo Profilo | Senior Member

Nessuna perchè difatti il problema sta nei singoli file js, se mi dai dei link dove scaricarli vedo se riesco a trovarti il problema.

iif Profilo | Expert

Questo è l'esempio funzionate completo.

Anonimo Profilo | Senior Member

Ho letto il codice a occhio e croce nel file menu.js la riga di codice che secondo me scatena l'errore è :

this.o_root = this;

quindi prova a spostare i tre file js nella stessa cartella della masterpage, dovrebbe funzionare.

iif Profilo | Expert

Ciao, ho provato a spostare il file .js, niente di fatto.

Codice della masterpage:

<%@ Master Language="VB" CodeFile="MasterPage.master.vb" Inherits="MasterPage" %>

<html xmlns="http://www.w3.org/1999/xhtml" >
<script type="JavaScript" src="menu.js"/>
<script type="JavaScript" src="menu_items.js"/>
<script type="JavaScript" src="menu_tpl.js"/>
<head>
<title>Pagina senza titolo</title>
<link rel="stylesheet" href="menu.css" />
</head>
<body>
<script type="JavaScript">new menu(MENU_ITEMS, MENU_TPL);</script>
<div>
<br />
<br />
<br />
<br />
<asp:contentplaceholder id="ContentPlaceHolder1" runat="server">
</asp:contentplaceholder>
</div>
</body>
</html>

Partecipa anche tu! Registrati!
Hai bisogno di aiuto ?
Perchè non ti registri subito?

Dopo esserti registrato potrai chiedere
aiuto sul nostro Forum oppure aiutare gli altri

Consulta le Stanze disponibili.

Registrati ora !
Copyright © dotNetHell.it 2002-2024
Running on Windows Server 2008 R2 Standard, SQL Server 2012 & ASP.NET 3.5