Friday 9 August 2013

How to Get ECMAScript Intellisence

When you will use ECMAScript library in Visual Studio, it’s possible to get intellisense for ECMAScript. There are three ways you may need to enable the intellisense:
Get Intellisense in Application Page: In the case you want to put your javascript in aspx file as inline, you need to add the following lines in the markup file. However, this will not work for webpart file. For webpart file you need to put your javascript in another js file as described in option 2.
<script type=”text/ecmascript” src=”/_layouts/SP.debug.js” />
<script type=”text/ecmascript” src=”/_layouts/SP.Debug.js” />
<script type=”text/ecmascript” src=”/_layouts/SP.Runtime.Debug.js” />
<script type=”text/javascript”>
// get intellisense here
</script>
Get Intellisense in js file: If you want to get intellisense in js file then you need to add the following lines in the top of the js file. As shown in the snippet below, the first reference is to MicrosoftAjax.js file. This is mandatory to have this js file reference at the top. Then I have added two other references. The two files (SP.Core.Debug.js and SP.debug.js) have basic SharePoint namespaces. However, if you need more functionalities try to add more js file reference from the path “C:/Program Files/Common Files/Microsoft Shared/Web Server Extensions/14/TEMPLATE/LAYOUTS”
Get Intellisense in webpart: To get intellisense in webpart you need to add the following two lines in the webpart ascx file:
<script type=”text/javascript” src=”/_layouts/MicrosoftAjax.js” ></script>
<script type=”text/javascript” src=”/_layouts/SP.debug.js” />

No comments:

Post a Comment