February's St. Louis DotNetNuke User Group presentation covered the basics of jQuery and how to use jQuery in DotNetNuke 4 and 5. Below you'll find both a PDF and PowerPoint version of the presentation. I'd recommend viewing the PPT version as the slides themselves are rather sparse but there are generaly slide notes included. I've also included the relevant code snippet from the DotNetNuke 4 demo below for reference.
Downloads
jQuery & DotNetNuke (PDF)
jQuery & DotNetNuke (PPT)
Utility Method for using jQuery in DotNetNuke 4 (from presentation demo)
This method utilizes an embedded resource to get the reference for the jQuery file. 4guys & google have more information about using embedded resources.
Notice the Utility type (Engage.Dnn.Framework.Utility) is passed in to both the IsClientScriptBlockRegistered and GetWebResourceUrl methods. You should change this to the name of the type that is responsible for adding this jQuery reference (in our case we specified Utility because this method appears in the Utility class). In other words, use the "current" type to further identify the client script web resource.
/// <summary
/// Adds a reference to jQuery 1.2.6 (minified) to the page. If you can reference DNN 5.0 or higher, use the built-in methods to register jQuery, instead.
/// </summary>
/// <remarks>
/// Adds the reference to the head of the page, rather than using <see cref="ClientScriptManager.RegisterClientScriptResource"/>
/// thus "guaranteeing" that it will run before other scripts (DNN Menu)
/// that might not react well to losing their $ reference.
/// Also checks for duplicates, only adding the reference once regardless of how many times this method is called for the <paramref name="page"/>.
/// </remarks>
/// <param name="page">The page to which the reference will be added.</param>
public static void AddJQueryReference(Page page)
{
const string JavaScriptReferenceFormat = @"<script src='{0}' type='text/javascript'></script>";
const string JQueryRegistrationKey = "jQuery Registration key";
if (!page.ClientScript.IsClientScriptBlockRegistered(typeof(Utility), JQueryRegistrationKey))
{
string jQueryReference = string.Format(CultureInfo.InvariantCulture, JavaScriptReferenceFormat, page.ClientScript.GetWebResourceUrl(typeof(Utility), "Engage.Dnn.Framework.JavaScript.jquery-1.2.6.min.js"));
page.Header.Controls.Add(new LiteralControl(jQueryReference));
page.ClientScript.RegisterClientScriptBlock(typeof(Utility), JQueryRegistrationKey, "jQuery(function($){$.noConflict();});", false);
}
}
Additional jQuery & ASP.NET Resources
Encosia (asp.net, ajax, and more)
Rick Strahl's Weblog (filtered by jQuery category)