Link to home
Start Free TrialLog in
Avatar of leskelly
leskellyFlag for United States of America

asked on

Reference to javascript file in master page not found

I have a master page in a .NET application which was developed in Visual Studio 2008 and which has references to 4 javascript files.  The references were created when I dragged and drop the files from the Solution Explorer into the header of the master page.  There is also a reference to a javascript file in the header content place holder of a page based on the master page.  There are no warnings regarding either page in the error list.but when I run the application and open the page an error is thrown for each reference that looks like this:
Webpage error details

User Agent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1; Trident/4.0; GTB6.5; .NET CLR 1.1.4322; .NET CLR 2.0.50727; .NET CLR 3.0.04506.30; .NET CLR 3.0.04506.648; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729; .NET CLR 1.0.3705; InfoPath.2; MS-RTC EA 2)
Timestamp: Thu, 12 Aug 2010 14:41:41 UTC

Message: Syntax error
Line: 3
Char: 1
Code: 0
URI: http://localhost:1846/login.aspx?ReturnUrl=%2fjs%2fLogin.js

Message: Syntax error
Line: 3
Char: 1
Code: 0
URI: http://localhost:1846/login.aspx?ReturnUrl=%2fjs%2fjquery%2fjquery-1.4.2.js

Message: Syntax error
Line: 3
Char: 1
Code: 0
URI: http://localhost:1846/login.aspx?ReturnUrl=%2fjs%2fjquery%2fjquery-1.4.2-vsdoc.js

Message: Syntax error
Line: 3
Char: 1
Code: 0
URI: http://localhost:1846/login.aspx?ReturnUrl=%2fjs%2fjquery%2fjQueryUI.js

Message: Syntax error
Line: 3
Char: 1
Code: 0
URI: http://localhost:1846/login.aspx?ReturnUrl=%2fjs%2fMaster.js

I've attached the code for the master and content pages.  Any assistance would be greatly appreciated.
<%@ Master Language="VB" CodeFile="ClientTrack.master.vb" Inherits="ClientTrack" %>

<!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 runat="server">
    <title>Site Master Page</title>
    <asp:ContentPlaceHolder id="head" runat="server"></asp:ContentPlaceHolder>
   
    <link href="/Styles/Master.css" rel="stylesheet" type="text/css" />
    <link href="/Styles/Dialog.css" rel="stylesheet" type="text/css" />

    <script src="../js/jquery/jquery-1.4.2.js" type="text/javascript"></script>    
    <script src="../js/jquery/jquery-1.4.2-vsdoc.js" type="text/javascript"></script>
    <script src="../js/jquery/jQueryUI.js" type="text/javascript"></script>
    <script src="../js/Master.js" type="text/javascript"></script>   
    
    <script type="text/javascript">
        window.onbeforeunload = confirmExit();
    </script>
    
</head>
<body>
    <form id="form1" runat="server">
        <asp:ScriptManager ID="ScriptManager1" runat="server">
            <Services>
                <asp:ServiceReference Path="~/WebServices/HelpService.asmx" />
            </Services>
        </asp:ScriptManager>
        <div id="divPageWrapper">
            <div id="divHeaderOne">
                <asp:Image runat="server" ID="HeaderImage" CssClass="HeaderOneImage" ImageUrl="~/Images/MasterHeader.gif"
                    AlternateText="Logo" />
            </div>
            <div id="divMenu">
                <asp:Menu CssClass="MainMenu" ID="MasterMenu" runat="server" DataSourceID="SiteMapDataSource1"
                    Orientation="Horizontal" StaticEnableDefaultPopOutImage="False">
                    <StaticSelectedStyle CssClass="StaticSelectedStyle" />
                    <StaticMenuItemStyle CssClass="StaticMenuItemStyle" ItemSpacing="0px" />
                    <StaticHoverStyle CssClass="StaticHoverStyle" />
                    <DynamicHoverStyle CssClass="DynamicHoverStyle" />
                    <DynamicMenuItemStyle CssClass="DynamicMenuItemStyle" />
                </asp:Menu>
            </div>
            <div id="divHeaderTwo">
                <asp:Label ID="lblFormTitle" runat="server" Text="FormTitle"></asp:Label>
            </div>
            <div id="divHeaderThree">
                <asp:UpdatePanel ID="UpdatePanelDDL" runat="server">
                    <ContentTemplate>
                        Records For
                        <asp:DropDownList ID="ddlRecordsFor" runat="server" Width="150px" CssClass="RecordsFor" AutoPostBack="True">
                            <asp:ListItem>1</asp:ListItem>
                            <asp:ListItem>2</asp:ListItem>
                            <asp:ListItem>3</asp:ListItem>
                        </asp:DropDownList>
                    </ContentTemplate>
                </asp:UpdatePanel>
            </div>
            <div id="divSideBar">
                <asp:LinkButton ID="LogOff" runat="server">Log Off</asp:LinkButton>
                <a id="SpellCheck" onclick="checkspell()">Spell Check</a><br />
                <a id="YouAre" onclick="YouAre()">You Are</a>
                <asp:HyperLink ID="YouCan" runat="server">You Can</asp:HyperLink>
                <asp:HyperLink ID="WhoCan" runat="server">Who Can</asp:HyperLink>
                <asp:HyperLink ID="HowCan" runat="server">How Can</asp:HyperLink>
                <asp:UpdateProgress ID="UpdateProgressButton" runat="server">
                    <ProgressTemplate>
                        <div class="Progress">
                        </div>
                        <br />
                        <div class="PleaseWait"> Please Wait...</div>
                    </ProgressTemplate>
                </asp:UpdateProgress>
            </div>
            <div id="divMainContent">
                <asp:ContentPlaceHolder ID="cp1" runat="server">
                    Under Construction
                </asp:ContentPlaceHolder>
            </div>
            <div id="divFooter">
                <asp:UpdatePanel ID="UpdatePanelButton" runat="server">
                    <ContentTemplate>
                        <asp:Button ID="btnDivideByZero" runat="server" Text="Divide by Zero" Width="125px" />
                        <asp:Button ID="btnPageNotFound" runat="server" Text="Page Not Found" Width="133px" />
                        <asp:Button ID="btnDatabaseError" runat="server" Text="Data base Error" Width="125px" />
                    </ContentTemplate>
                </asp:UpdatePanel>
            </div>
        </div>
        <asp:SiteMapDataSource ID="SiteMapDataSource1" runat="server" ShowStartingNode="False" />
        <div id="divHelp"></div>
    </form>
</body>
</html>

<%@ Page Language="VB" MasterPageFile="~/MasterPages/ClientTrack.master" AutoEventWireup="false" CodeFile="Login.aspx.vb" Inherits="Login" Title="Login" %>

<asp:Content ID="Content2" ContentPlaceHolderID="head" runat="Server">
    <script src="../js/Login.js" type="text/javascript"></script>
</asp:Content>

<asp:Content ID="Content1" runat="server" ContentPlaceHolderID="cp1">

    <asp:ScriptManagerProxy ID="ScriptManagerProxy1" runat="server">
        <Services>
            <asp:ServiceReference Path="~/WebServices/LoginService.asmx" />
        </Services>
    </asp:ScriptManagerProxy>

    <div id="divLogin" title="Login">
        <asp:Label ID="lblUserName" runat="server" Text="User Name:"></asp:Label>
        <asp:TextBox ID="txtUserName" runat="server"></asp:TextBox>
        <br />
        <asp:Label ID="lblPassWord" runat="server" Text="Pass Word:"></asp:Label>
        <asp:TextBox ID="txtPassWord" runat="server" TextMode="Password"></asp:TextBox>
        <br />
        <input id="btnLoginHtml" type="button" value="LoginHtml" onclick="Login(ctl00$cp1$txtUserName.value, ctl00$cp1$txtPassWord.value)" />
     <%--   <asp:Button ID="btnLogin" runat="server" Text="Login" />--%>
    </div>
</asp:Content>

Open in new window

Avatar of Zvonko
Zvonko
Flag of North Macedonia image

Nprmaly it do not have to change anything but remove all ".." at the beginning of your .js paths.
Like this:

    <script src="/js/jquery/jquery-1.4.2.js" type="text/javascript"></script>    
    <script src="/js/jquery/jquery-1.4.2-vsdoc.js" type="text/javascript"></script>
    <script src="/js/jquery/jQueryUI.js" type="text/javascript"></script>
    <script src="/js/Master.js" type="text/javascript"></script>  


Do not forget this one:
    <script src="/js/Login.js" type="text/javascript"></script>


Good luck!

Avatar of leskelly

ASKER

Hello Zvonka,

Thanks for the suggestion but I'm afraid it didn't make any difference.  Any other ideas?
The check is simple: that what you expect to be accessible by the page as .js file has to be accessible for you also in the browser address bar.
That mean, enter this address in browser and check the existence of the file:

http://localhost:1846/js/jquery/jquery-1.4.2.js

If you get the 404 page not fount error then simply that file is not there.
Look on the web server directory at the root of all you pages and check what is wrong with the paths.

The files are definitely there as I had said I created the references by dragging them to the master page however I do get the 404 error.  This is most peculiar as I get it even if I try to open the file by going through the Directory listing.  In the attached file you can see that the jquery-1.4.2.js file shows up as a link in the directory listing but if I click on the link I get the 404 error.  This must be a permissions issue.


Doc1.doc
Actually I'm still unsure of the problem.  The login.aspx page is the start page for the project so when I tried to open any other file I got redirected to it.  I excluded it from the project thinking that would remove it as the start up page but it didn't so the 404 error was caused because the browser couldn't find the login page.
I would the location in Visual Studio to change the start options.  I tried leaving the start page blank then I tried setting it to the URL of one of the javascript files but if I try to browse to any file in the application I get redirected to the login page.  Still I know the file is there as the attached document from two post ago shows.  Do you have any other thoughts?
That localhost:1864 port is serving request only during that time when you start such an page in your development IDE.

Therefore either upload that project to a server or let the serving request open while you do the tests in browser.

I have to check how VisualStudio runs that stuff and will come back. You use VisulaStudio?, right?

Yes, I'm using Visual Studio 2008.
ASKER CERTIFIED SOLUTION
Avatar of jhp333
jhp333
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Hello,

and thanks for your response.
How do you allow *.js files?

Right now I'm working on my development machine and using the Visual Studio Development Server.
As the user is not yet authenticated when on the log in page I had to allow anonymous access to the folder the Javascript files are in.  I did this by adding the code below to the web.config file.  I believe this is what  jhp333 was referring to above.
<location path="js">
    <system.web>
        <authorization>
            <allow users="?" />
        </authorization>
    </system.web>
</location>

Open in new window

See my final comment.