Getting jQuery to work with MasterPages

Maybe someone from the ASP.Net community can enlighten me, I have always had the hardest time getting the script, css, etc working/rendering correctly when used on the masterpage. On the masterpage I always have to use an absolute path on the script or link tag or generate the script/link tag from the code behind on the masterpage in order for it to render/execute properly. Is there a better method. I recently ran accross this using jQuery trying to get the intellisense to work on the pages inheriting the master page.This is what I came up with. Seems like a hack. Any suggestions?

MasterPage head tag:

Head

I read Scott G's post on jQuery and intellisense and it works great for non-masterpaged files.  Does anyone else have methods that don't seem so hacked.

Published Wednesday, December 24, 2008 10:28 AM by rojay12
Filed under: , ,

Comments

# re: Getting jQuery to work with MasterPages

Wednesday, December 24, 2008 3:06 PM by Frederik

I usually use <script src="<%= ResolveClientUrl('~/scripts/jquery.js') %>" type="text/javascript"></script>

# Getting jQuery to work with MasterPages - Code Junkie

Wednesday, December 24, 2008 11:27 PM by Marc LaFleur

Jared Roberts asked a question today on his blog about using jQuery with ASP.NET Master Pages ( Getting

# re: Getting jQuery to work with MasterPages

Wednesday, December 24, 2008 11:45 PM by MarcLaFleur

Hi Jared, hope this posts helps you out - weblogs.asp.net/.../getting-jquery-to-work-with-masterpages-code-junkie.aspx. We ran into this same issue and went though a lot of trial and error before landing with this solution.

# re: Getting jQuery to work with MasterPages

Friday, December 26, 2008 11:30 AM by rojay12

Thanks Marc. Perferrably Alternative.

# Getting jQuery to work with MasterPages &laquo; Ghost&#8217;s Weblog

Monday, December 29, 2008 12:28 PM by Getting jQuery to work with MasterPages « Ghost’s Weblog

Pingback from  Getting jQuery to work with MasterPages  &laquo; Ghost&#8217;s Weblog

# re: Getting jQuery to work with MasterPages

Wednesday, December 02, 2009 5:53 PM by waleed

Asp.net Master page and JQuery reference – JS Inside Master Pages:

ledomoon.blogspot.com/.../aspnet-master-page-and-jquery-reference.html

# re: Getting jQuery to work with MasterPages

Wednesday, December 02, 2009 5:54 PM by ledo_moon

Asp.net Master page and JQuery reference – JS Inside Master Pages:

ledomoon.blogspot.com/.../aspnet-master-page-and-jquery-reference.html

# re: Getting jQuery to work with MasterPages

Saturday, December 04, 2010 4:28 AM by Ralaad

jQuery didnt work when postback is true..

how to fix this.

this erorr occured only when using master page.

Leave a Comment

(required) 
(required) 
(optional)
(required)