Thursday, March 1, 2012

SharePoint 2010 Client Side ECMA Script - Intellisense Enabling

There are different ways to enabling ECMA script intellisense

For Application Page

  1. Add New Item to you Empty SharePoint project
  2. In the New Item dialog box, in the Installed Templates pane, expand Visual C#, expand SharePoint, and then click 2010.
  3. To the right of the Installed Templates pane, click Application Page.
  4. In the Name box, type the name that you want to use for your application page.
  5. Click Add.
  6. On the application page, in the PageHead content placeholder, add the following code
     
    <% #if SOME_UNDEFINED_CONSTANT %>
    <script type="text/javascript" src="/_layouts/SP.debug.js" >script>
    <% #endif %>
     
    Notice that the Visual Studio 2010 status bar indicates that it is updating the JavaScript IntelliSense for your page, as shown by the following illustration.
    Ff798328.a39fca9a-f7f9-49d2-8747-a5e3bc70f755(en-us,PandP.10).png
    On the application page, in the PageHead content placeholder, use the following code to add another script tag and create a JavaScript function.

    Now you intellisense should be working
For Visual Web Part
  1. Add New Item to you Empty SharePoint project
  2. In the New Item dialog box, in the Installed Templates pane, expand Visual C#, expand SharePoint, and then click 2010.
  3. To the right of the Installed Templates pane, click Visual Web Part.
  4. In the Name box, type the name that you want to use for your Visual Web Part.
  5. Click Add.
  6. In the Visual Web Part .ascx file, add the following code.
    <% #if SOME_UNDEFINED_CONSTANT %>
     <script type="text/javascript" src="/_layouts/MicrosoftAjax.js" >script>
     <script type="text/javascript" src="/_layouts/SP.debug.js">script>
    <% #endif %>

For Standalone Javascript File
  1. In the Solution Explorer window, right-click the project node, point to Add, and then click New Item.
  2. In the New Item dialog box, in the Installed Templates pane, expand Visual C#, and then click Web.
  3. To the right of the Installed Templates pane, click Jscript File.
  4. In the Name box, type the name that you want to use for your JavaScript file.
  5. Click Add.
  6. In the JavaScript file, add the following code. 
<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" >


Hope this helps

No comments:

Post a Comment

Post a Comment

Follow by Email