Showing posts with label ECMA. Show all posts
Showing posts with label ECMA. Show all posts

Friday, February 10, 2012

Enabling IntelliSense for Client Object Model script in Visual Studio

Message
A simple way to enable/activate IntelliSense in Visual Studio while writing ECMA script. It allows, for example,  to write your javascript or jQuery code for SharePoint saving you a lot of time.
Some references: http://msdn.microsoft.com/en-us/library/ff798328.aspx

Context
Visual Studio 2010, SharePoint 2010, Visual WebPart

Explanation
Following is the list of debug .js files present in _layouts folder and depending upon the objects you are working with, you may need to add a reference to any of them to get IntelliSense.
  • SP.debug.js (to get IntelliSense on list objects)
  • SP.Core.debug.js
  • SP.Ribbon.debug.js
  • SP.Runtime.debug.js
  • JsGrid.debug.js
  • JsGrid.Gantt.debug.js


Solution
Add following lines at the start of the .ascx file in a visual webpart.

<script type="text/javascript" src="/_layouts/MicrosoftAjax.js"></script>
<script type="text/javascript" src="/_layouts/SP.Debug.js"></script>
<script type="text/javascript" src="/_layouts/SP.Core.debug.js">

PS: Exclude these references while deploying the code to production environment.