views:

2272

answers:

3

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>
A: 

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

John JJ Curtis
The jQuery script reference is in the Master Page and the external script reference is in the web page that inherits the master page.
Jeff
When you do 'View Source' from the browser, does your external script reference appear below the jquery script reference?
John JJ Curtis
Yes, the external script appears after the jquery reference
Jeff
Are you willing to post what both your <script>...</script> tags look like in the aspx / master pages?
John JJ Curtis
Two other things I might try: put your rule.js include tag in the master page right below all the other script tags. If that does not work, try putting it at the very bottom of the master page, right before the </form> tag.
John JJ Curtis
I tried your suggestion and get the same result
Jeff
A: 

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.

Damien
I am not sure of what you mean by "put a ContentPlaceHolder in the tag". Would you mind elaborating?
Jeff
+1  A: 

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.

Jeff
Glad you figured it out :)
John JJ Curtis