Search This Blog

Friday, February 11, 2011

Enabling Intellisense in Sharepoint javascript client OM :Sharepoint 2010

We recently came across a requirement in one of our projects to write code in javascript client OM like checking which features are enabled on the web.While we are writing code in javascript client OM, one of the things you would love to have is intellisense which can help you find the right methods to use in the client OM.

Well, I decided to explore more on this and found that you can enable sharepoint intellisense in a javascript file (in Visual Studio 2010) by adding following 2 lines of code on the top of your javascript file:

/// <reference path="C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\TEMPLATE\LAYOUTS\MicrosoftAjax.js" />
/// <reference path="C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\TEMPLATE\LAYOUTS\SP.debug.js" />

Adding these lines enables the intellisense as you can see in the screenshot:

Here, I have added reference to 2 of the files in the '14 hive' layouts directory.Depending on your need , you might need to add reference to other javascript files in this directory to enable intellisense.

We can also add this intellisense to application pages and visual webparts.More details on this can be found in this article in MSDN:

No comments:

Post a Comment