Your official information source from the .NET Web Development and Tools group at Microsoft.
It should be no surprise that JScript Documentation Comments power much of what you see in JScript IntelliSense in VS2008. Perhaps the most useful of these comments is the "reference" comment. The "reference" comment allows you to "see" functions and objects outside of your current file in the completion list. I've gotten quite a few questions about this feature so, I wanted to provide a reference for when and how to use it. There are four usage patterns:
Referencing Another JS File
/// <reference path="path-to/another-script.js" />
If the "path" attribute points to another JS file, any objects or functions defined inside that file-or in a file referenced by that file-will show up in IntelliSense. Yes, this implies a transitive closure. The intent was to reduce the number of references you would need on any given file. Thus, don't be surprised if more scripts show up to the party than you invited!
Referencing a Web Service
/// <reference path="path-to/wcf-service.svc" />/// <reference path="path-to/asmx-service.asmx" />
If the "path" attribute points to a web service (either WCF or ASP.NET), any objects or functions defined in the generated proxy for that service will show up in IntelliSense. Web service proxies in JScript are an ASP.NET AJAX feature. Therefore it is critical that you reference "MicrosoftAjax.js" before you reference any web services.
Referencing a Web Page
/// <reference path="path-to/default.aspx" />
If the "path" attribute points to a page (an ASPX, HTML, or Master), IntelliSense will behave as if you were on the page. This mode is really just syntactic sugar and behaves equivalently to manually copying each script reference from the page over to your script file. The only difference is that you will not see any inline script blocks reflected in IntelliSense. However, you will be able to reference any elements with an ID on the page. Any scripts or elements included via a Master page will also be reflected. This mode useful for scripts that are meant to be paired exclusively with a markup page, i.e. in a "code-beside" fashion.
Referencing an Embedded Resource
/// <reference name="resource-name" />/// <reference name="resource-name" assembly="assembly-name" />
We recognized that scripts will frequently be embedded inside an assembly. To reference such a script, set the "name" attribute to the resource name, and set the "assembly" attribute to the assembly name. The "assembly" attribute is optional. If left out, System.Web.Extensions will be assumed as the assembly. This is why referencing "MicrosoftAjax.js" does not require an "assembly" attribute.
Here are a few other subtle tips:
Hope this helps!
Jeff KingProgram ManagerVisual Studio Web Tools
Hi Hal Hovland: We restrict references to only those files inside the current project (or web site). We've since realized this was too restrictive and are working on relaxing this in the next update of VS. Thanks!
Nov 17th Links: ASP.NET, ASP.NET AJAX, ASP.NET MVC, VS 2008, .NET 3.5, IIS7, Silverlight
A while back we updated IntelliSense to not fail when referencing jQuery. However, getting IntelliSense
Last week I mentioned we would be releasing a Hotfix to accompany our new jQuery VSDoc file . This Hotfix
I’ve been thinking for a while about how people tend to build AJAX applications, as there seems to be