October 15, 2009

How-To: Add intellisense support for Jquery inside UserControl page in Visual Studio 2008 IDE

If you have just downloaded and referenced Jquery , you might be wondering how to add intellisense support for the same in user control.


A blog post by scott gu shows very nicely how microsoft has included a hotfix for visual studio 2008 sp1 which enables jquery intellisense support (provided you also reference the jquery vsdoc file in your project).



I was trying out JQuery on normal aspx page and it worked just fine. However I soon ran into problem while using it in a user control, the intellisense simply was not working. I did a quick work around for the same which is as follows:

Just write down if statements within your user control which evaluates to false always and reference the jquery script file there. Note I already have a referenced jquery lib in my master page, and I don’t want it to be rendered a second time here, hence the if statement.

This code will server two purposes: firstly it will allow visual studio IDE to detect and display intellisense when you use jquery syntax in your user control, secondly it won’t show up in the rendered html since if always evaluates for false.


 
 
 
There may be other optimal solutions available out there, but this code did the trick for me and it can be removed before publishing the site for production purposes.

Get More information from our sharepoint Consulting Staff.

Posted By: Bhavyesh

No comments:

Post a Comment