Will "the Mighty" Strohl

jQuery Intellisense in DotNetNuke Module Development

One cool thing about the recent releases of DotNetNuke® is that they include the intellisense file for jQuery in the installation and source.  What is that file for?  Well, that’s quite simple.  It allows you to have intellisense for jQuery the same way that you have it for VB and C#.  Here’s how you can take advantage of that when developing modules in DotNetNuke®.

First of all, Scott Guthrie already does a great job of explaining how to get jQuery intellisense enabled in Visual Studio, so I will not rehash that information.  Just read his blog post about it and come back here.  Don’t take too long though, because I have a short attention span…

<beginIntermission>

Okay, you should have follow Scott’s steps in the above paragraph. Now let’s get back to DNN.

</beginIntermission>

First of all, there is a difference in how you handle jQuery from version 5.01.00 and those that came before it.  For those versions that are lower, you will need to add the intellisense file to the website project.  If you need to do that, put it in the following directory with the following name:

~/Resources/Shared/scripts/jquery/jquery.intellisense.js

Doing this will ensure that you follow the same directory and file naming convention, and further ensures that subsequent upgrades of DNN does not break your module.  Of course, commercial modules may have to come up with a different solution to support a wider variety of DNN installations.  (Also, you may have to give further consideration to jQuery versions.)

Now that the file is in place, open the mark-up for any user control in your module source.  Add the following line of HTML code:

<script language="javascript" type="text/javascript" 
    src="~/Resources/Shared/scripts/jquery/jquery.intellisense.js"></script>

That’s it!  Seriously… There is nothing else to it.  Now, when you begin using jQuery in your mark-up, you will be able to enjoy intellisense like you already do with your managed code.  Notice in the screen shot below how you not only have intellisense, but you also have contextual information about the members.  Awesome!

jQuery Intellisense in Visual Studio

This is only useful for module development though.  MAKE SURE that you remove the jQuery intellisense file reference from your mark-up before deploying your module.



blog comments powered by Disqus