Question

I am using ASP.NET 3.5 with MasterPages. My master page has the script references to jquery and jquery UI. My web page that uses the master page has a script reference for a custom javascript file for that page. This javascript file has jquery calls in it (i.e. document.ready --> set up input boxes as calendars).

When I run the website in debug from Visual Studio, the input boxes are not set as calendars. However, if I copy the script from the external file and include it in a script block in the web page, the input box becomes a calendar.

I also have an element in the child page (not sure if that makes a difference). I have referenced the external javascript file in the ScriptManager and outside of the ScriptManager and neither work.

Why does jQuery not work in an external javascript file when the jQuery script reference resides in the master page?

Any help would be appreciated.

Thanks

MASTER PAGE CODE

<head id="Head1" runat="server">
    <title>Customer Agreement Lifecycle Management System </title>
     <link rel="stylesheet" type="text/css" href="~/calms.css" />
    <link href="css/ui-lightness/jquery-ui-1.7.1.custom.css" rel="stylesheet" type="text/css" />
    <script type="text/javascript" src="<%=ResolveUrl("~/js/jquery-1.3.2.min.js") %>"></script>
    <script type="text/javascript" src="<%=ResolveUrl("~/js/jquery-ui-1.7.1.custom.min.js") %>"></script>
</head>

CHILD PAGE CODE

<asp:Content ID="Content1"   ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">

    <script src="<%=ResolveUrl("~/js/rule.js") %>" type="text/javascript"></script>

    <asp:ScriptManager ID="ScriptManager1" runat="server">
    </asp:ScriptManager>
Was it helpful?

Solution

I want to thank everyone for their suggestions but I made a "bone-headed" mistake. The tags were mistakenly still in the external js file. Once removed, everything works as expected. I apologize for taking up everyone's time (and somewhat embarrassed).

Thanks.

OTHER TIPS

Is the external script include below the jquery script? Maybe it's the order in which the scripts are being loaded and run...

Are you sure the reference to the jQuery file in the child object appears in the head of the HTML document?

If not, put a ContentPlaceHolder in the tag and put the references you need in each child page.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top