views:

33

answers:

3

I have an ASP.NET application using a master page. I am adding a reference to the JQuery library in the master page however there are some content pages and user controls that reference the JQuery library directly. Will I need to remove each reference from those pages or can I leave them in place even though I am adding a reference into the master page of the application?

A: 

You should remove them, including the library twice has many side-effects, wiping out any plugins defined for example. It'll load fine, but you'll start getting .pluginMethod is not defined, etc.

To avoid the headaches, only include them once, or register the script with the same key, and let ASP.Net do the include, and with the same key, it'll do so only once.

Nick Craver
A: 

You will need to remove them I'm afraid. Came across this issue myself and the javascript will break.

Roger Walsh
Yeah that what I was afraid of. Not a terrible problem because the application has just started using features implemented in JQuery but now the site needs it to be a global reference.
Achilles
+1  A: 

If you're loading jQuery with the Script Manager, it should load only once.

If you still want intellisense, you can use the following trick:

<% if (false) { %>
  <script src="....... script tag here
<% } %>
Atømix
This isn't quite what I was doing, but your suggestion did give me the idea I used to solve my "backwards compatibility" problem. +1
Achilles