Sunday, January 30, 2011

Using jQuery in Webforms 2.0 with Master pages

If you want to use jQuery in Webforms 2.0 with master pages, one way to get jQuery working in other pages is to reference the jQuery scripts in the HEAD tag using ResolveUrl method in the SRC attribute of the SCRIPT tag, like so:

ResolveUrl("~/Scripts/jquery-1.4.1.js")

Note: The jQuery source file is located under a Scripts folder here.

I have seen plenty of examples of slideToggle() and the show()/hide() methods on the internet using a simple div/panel container. This dont work the way you want it, if there is a gridview with a button (say for inline editing with an edit button) nested inside the parent container. The postback caused by clicking the button inside the grid is likely to mess up whatever code you have to create the slideToggle etc.

Has anyone of you encountered a similar issue?