65.9K
CodeProject is changing. Read more.
Home

Enabling JavaScript intellisense in VS.NET 2010 to work with SharePoint 2010

starIconstarIconstarIconstarIconstarIcon

5.00/5 (1 vote)

Apr 15, 2010

CPOL
viewsIcon

40120

To enable JS intellisense in Visual Studio 2010, you have two options (there are others to do with reference tag name and assembly) but these are the ones that I know work.i) Add a JavaScript file to an AJAX server control project (which references System.Web.Extensions and hence the...

To enable JS intellisense in Visual Studio 2010, you have two options (there are others to do with reference tag name and assembly) but these are the ones that I know work. i) Add a JavaScript file to an AJAX server control project (which references System.Web.Extensions and hence the embedded resource MicrosoftAJAX.js - you could also probably add an assembly reference to a web.config for the same effect but I haven't tried it). ii) Add the following reference tags to the top of the JS file:
/// <reference name="MicrosoftAjax.js"/>
/// <reference path="C:\\path-to-js\\SP.UI.Dialog.debug.js"  />
iii) Add JS equivalent 'using' statements to top of JS (below reference) - Type.registerNamespace("SP.Ribbon"); etc. The other way is to add:
<asp:ScriptManagerProxy ID="ScriptManagerProxy1" runat="server">
    <Scripts>
        <asp:ScriptReference Path="~/SP.UI.Dialog.debug.js" />
    </Scripts>
</asp:ScriptManagerProxy>
<script type="text/javascript">
...script
 </script>
to an aspx page. Use Ctrl + Shift + J to update javascript intellisense in visual studio. Adding the debug version is needed because the non debug version is compressed for performance reasons using an older version of Script#.