{"id":4004,"date":"2008-11-18T12:30:40","date_gmt":"2008-11-18T12:30:40","guid":{"rendered":"https:\/\/blogs.msdn.microsoft.com\/webdev\/2008\/11\/18\/jscript-intellisense-faq\/"},"modified":"2008-11-18T12:30:40","modified_gmt":"2008-11-18T12:30:40","slug":"jscript-intellisense-faq","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/dotnet\/jscript-intellisense-faq\/","title":{"rendered":"JScript IntelliSense FAQ"},"content":{"rendered":"<p>I&#8217;ve been reading through the 70 or so comments on our last 2 jQuery posts.&nbsp; There have been a lot of great questions.&nbsp; Apologies for not being able to answer them sooner (I was busy preparing for Dev Connections).&nbsp; Instead of answering them inline with the comments, I&#8217;ll try to paraphrase the popular issues here and answer them centrally.<\/p>\n<p><strong>1. I have a ton of Content Pages, do I need to put script references for IntelliSense in each one?<\/strong><\/p>\n<p>No, you do not need to repeat the script references on each content page.&nbsp; Visual Studio 2008 will auto-detect the presence of a master page and scan for references in that file.&nbsp; Thus, placing references in the master page is all you need to do.<\/p>\n<p><strong>2. I put a vsdoc reference in the Master Page, why is IntelliSense not working in a User Control?<\/strong><\/p>\n<p>User Controls do not specify a master page.&nbsp; Thus, there is no way for Visual Studio to guess which master page the user control will end up on.&nbsp; Generally, we simply can&#8217;t predict which file a user control will end up on.&nbsp; Thus, we are unable to provide IntelliSense.<\/p>\n<p>&#8220;Shail&#8221; provided the best suggestion, which is just to include a list of script references you want on your user control, then wrap those controls with a &#8220;&lt;% if (false) &#8230; %&gt;&#8221; to make sure you don&#8217;t redundantly include scripts at runtime.<\/p>\n<p>I can see a centralized list of references helping this scenario, which leads into the next question&#8230;<\/p>\n<p><strong>3. Is there a way to specify a centralized list of references for IntelliSense?<\/strong><\/p>\n<p>Unfortunately, not right now.&nbsp; Short of writing your own ScriptManager or similar code, there&#8217;s no &#8220;built-in&#8221; way to specify a centralized list of references for IntelliSense (or for the runtime).&nbsp; There&#8217;s no web.config location for this (as &#8220;CurlyFro&#8221; asked) nor is there a Tools Options list you can set.<\/p>\n<p>However, there is a fairly useful trick that is worth mentioning.&nbsp; You can create a JS file with no code (let&#8217;s call it &#8220;list.js&#8221;) that contains solely a list of commonly used references (the XML comment type) at the top.&nbsp; Instead of putting a list of individual references on top of each JS file, you can simply include just a reference to &#8220;list.js&#8221;.&nbsp; The meta-point here is that <strong>references originating from a script (not HTML\/ASPX) file are<\/strong> <strong>transitive<\/strong>.&nbsp; If A references B, and B references C and D&#8230; A effectively references B,C, and D.&nbsp; Having the centralized file saves you from updating 100&#8217;s of files when you add one more script to your project.&nbsp; As mentioned above, Master Pages serve as a unified place to put scripts for HTML\/ASPX pages.<\/p>\n<p>&#8220;Peter&#8221; suggested there was a similar issue with CSS files.&nbsp; Given the feedback, this is something we can definitely take into consideration.&nbsp; I&#8217;m curious: how many files you are typically including into your pages?&nbsp; Will the workarounds provided suffice?<\/p>\n<p><strong>4. Which URL-path types does IntelliSense recognize?<\/strong><\/p>\n<p>I saw a lot of questions\/feedback\/comments regarding paths and URLs.&nbsp; I&#8217;d like to clarify what is supported and not supported by Visual Studio JScript IntelliSense then ask for feedback:<\/p>\n<ul>\n<li><strong>File-Relative Paths<\/strong> &#8211; These are paths of the form &#8220;..\/..\/folder\/file&#8221;, and is calculated from the current file(http:\/\/site\/application\/folder\/<strong>file<\/strong>).&nbsp; Visual Studio, ASP.NET Web Forms, and ASP.NET MVC all support this type of path and resolve these correctly.&nbsp; The challenge, however, is with master pages.&nbsp; This type of path is not re-based when a master page is merged with a content page. Thus if you content pages are at varying folder depths, your paths will be broken.&nbsp; Incidentally, ASP.NET MVC folder paths tend to be exactly two levels deep because of the conventional MVC dictated folder structure of &#8220;Views\/ControllerName&#8221;.&nbsp; Because of this, I would recommend this type of path for MVC, but not for Web Forms. <\/li>\n<li><strong>App-Relative Paths<\/strong> &#8211; These are paths of the form &#8220;~\/folder\/file&#8221;, and is calculated from the base of your application (http:\/\/site\/<strong>application<\/strong>\/folder\/file).&nbsp; Visual Studio and ASP.NET Web Forms both support this type of path provided you specify it inside a Script Manager (and a few other runat=server controls).&nbsp; Since ASP.NET MVC is not normally used with Script Manager controls, app-relative paths will not work with MVC.&nbsp; By the way, this type of syntax is not supported inside plain &lt;script&gt; tags regardless of technology.&nbsp; App-relative paths are re-based when a master page is merged with a content page.&nbsp; Thus it is not broken by content pages at varying folder depths.&nbsp; Thus I would recommend this approach for Web Forms.&nbsp; The Script Manager normally injects MS AJAX into your rendered page.&nbsp; What if you are not using MS AJAX?&nbsp; The Script Manager <a href=\"http:\/\/weblogs.asp.net\/bleroy\/archive\/2008\/07\/07\/using-scriptmanager-with-other-frameworks.aspx\">can be modified to not to inject MS AJAX<\/a>. <\/li>\n<li><strong>Site-Relative Paths<\/strong> &#8211; These are paths of the form &#8220;\/folder\/file&#8221;, and is calculated from the base of your site (http:\/\/<strong>site<\/strong>\/application\/folder\/file).&nbsp; This approach is supported by ASP.NET Web Forms and ASP.NET MVC.&nbsp; However, it is <strong>not<\/strong> supported by Visual Studio.&nbsp; The reason is because Visual Studio does not always know the final deployed location of your site and thus the path resolution cannot be guaranteed.&nbsp; Given that quite we&#8217;ve seen few folks are using site-relative paths, we could consider making an assumption just resolving this type of path to the root of the project.&nbsp; Given the risk that you may think your site is working when it&#8217;s really not, I wanted to see how many people were supportive of this. <\/li>\n<li><strong>Absolute Paths <\/strong>&#8211; Obviously, by absolute, I mean paths of the form &#8220;http:\/\/site\/etc&#8221;.&nbsp; Note, as of Service Pack 1, we will now resolve this type of path&#8230; fetching the file over the network if necessary. <\/li>\n<\/ul>\n<p>In a nutshell, I&#8217;m recommending ..\/..\/folder\/file for MVC and ~\/folder\/file for Web Forms.&nbsp; Also, we can resolve site-relative paths to the project root for if there&#8217;s enough demand.<\/p>\n<p><strong>5. How do I get IntelliSense to understand &#8220;google.load()&#8221;?<\/strong><\/p>\n<p>The google API has a dynamic way of including script files via the &#8220;load&#8221; function.&nbsp; Unfortunately, IntelliSense will not be able to understand that this function brings in new scripts.&nbsp; My recommendation here would be to include your file statically via a &lt;script&gt; tag.&nbsp; You can wrap it a &#8220;&lt;% if (false) &#8230; %&gt;&#8221; if you won&#8217;t want to double-include the script at runtime.<\/p>\n<p><strong>6. I&#8217;m getting a &#8220;childNodes is null&#8221; error, what is it and what do I do?<\/strong><\/p>\n<p>If you&#8217;re using jQuery, the &#8220;childNodes&#8221; error is indicative of IntelliSense not happy with a particular plug-in.&nbsp; Note, the error will misleadingly point to the jquery-1.2.6-vsdoc.js file.&nbsp; The cascading set of errors lands in the core jQuery code, however it originates from the plug-in.&nbsp; For example, the jQuery UI DatePicker is one of the plug-ins that will show this error.<\/p>\n<p>Generally for any JavaScript library, a &#8220;childNodes&#8221; error is caused by libraries that try to create DOM elements on parse rather than slightly later on load.&nbsp; DOM element creation is not supported at design-time (IntelliSense-time as I call it) and thus you get a null reference exception when you try to call &#8220;childNodes&#8221; on the element.&nbsp; Note, this is a perfectly acceptable pattern&#8230; it&#8217;s our fault that it causes an error.&nbsp; In fact, we&#8217;ve made some major architectural changes to accommodate this in Visual Studio 2010 but I&#8217;ll save that for another post.<\/p>\n<p>We will try to work with library owners to product VSDOC files for their libraries in the future.&nbsp; For now, the best option is to hide the file from IntelliSense&#8230;&nbsp; see question #8.<\/p>\n<p><strong>7. What makes a jQuery plug-in incompatible or compatible for IntelliSense?<\/strong><\/p>\n<p>There&#8217;s no hard and fast rule for compatibility with IntelliSense.&nbsp; However, from my experience, if a plug-in is going be incompatible, it&#8217;s going to be because it tries to create and modify a DOM element before the document is ready.&nbsp; Please see the previous question for more details.&nbsp; If you frequently see another type of issue, please let us know (via a comment on this post or you can email me&#8230; address at the bottom) and we&#8217;ll be sure to investigate to provide an explanation.<\/p>\n<p><strong>8. How do I hide a file from IntelliSense?<\/strong><\/p>\n<p>&#8220;Igor&#8221; came up with a clever solution outside the box of what the &#8220;vsdoc&#8221; feature was originally intended for. =)&nbsp; However, I think it&#8217;s great and worth repeating.&nbsp; You simply create a empty -vsdoc.js file for the offending library&#8230; effectively making Visual Studio skip the problematic ones.&nbsp; Of course this means you get less IntelliSense, but it&#8217;s better than none.<\/p>\n<p><strong>9. Can you add support to recognize more file extensions?<\/strong><\/p>\n<p>I saw a request from &#8220;Jerry&#8221; to recognize the &#8220;dash debug&#8221; convention.&nbsp; I also saw some folks mistakenly use a &#8220;dot vsdoc&#8221; naming scheme.&nbsp; Note vsdoc is supposed to be a &#8220;dash vsdoc&#8221; rather than &#8220;dot&#8221;.&nbsp; Of course there&#8217;s also the &#8220;dot min&#8221; extension for compressed files.&nbsp; We can definitely add support for more file extensions in a future release.&nbsp; Feedback for which ones are the most important would be helpful in making sure we support the right set.<\/p>\n<p><strong>10. In Visual Studio 2005 I am getting no IntelliSense, what do I need to do?<\/strong><\/p>\n<p>You&#8217;ll need to upgrade to Visual Studio 2008.&nbsp; I hate to pull the &#8220;buy a new version&#8221; card, but JScript IntelliSense was a fairly involved code change and it would be non-trivial to back-port it to Visual Studio 2005.<\/p>\n<p><strong>11. Is there a way to get around closing and reopening an file to get Visual Studio to update IntelliSense?<\/strong><\/p>\n<p>Yes.&nbsp; Please use <strong>Ctrl + Shift + J<\/strong> to manually force JScript IntelliSense to update.&nbsp; For menu-lovers, this command can be found under Edit, IntelliSense, Update JScript IntelliSense.<\/p>\n<p><strong>Summary<\/strong><\/p>\n<p>I hope this FAQ clears up the common points of confusion.&nbsp; I saw a few comments akin to &#8220;because of ____, this feature is useless to me.&#8221;&nbsp; As harsh as they sound, those comments are the most useful to us.&nbsp; If there&#8217;s something in your way, feel free to email me at jking at microsoft dot com.&nbsp; I&#8217;d like to see if there&#8217;s something we can figure out for you.&nbsp; Thanks for reading!<\/p>\n<p><b>Jeff King<\/b>     <br>Program Manager     <br>Visual Studio Web Tools<\/p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>I&#8217;ve been reading through the 70 or so comments on our last 2 jQuery posts.&nbsp; There have been a lot of great questions.&nbsp; Apologies for not being able to answer them sooner (I was busy preparing for Dev Connections).&nbsp; Instead of answering them inline with the comments, I&#8217;ll try to paraphrase the popular issues here [&hellip;]<\/p>\n","protected":false},"author":404,"featured_media":58792,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[197],"tags":[7279,31,7288,7276,7277,7274,7286,7303,147,7302,7316,7319,7292,7267],"class_list":["post-4004","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-aspnet","tag-ajax","tag-asp-net","tag-asp-net-mvc-framework","tag-intellisense","tag-jeff-king","tag-jscript","tag-mvc","tag-sp1","tag-visual-studio","tag-visual-studio-2008","tag-visual-studio-2008-sp1","tag-visual-web-developer","tag-vs2008","tag-vwd"],"acf":[],"blog_post_summary":"<p>I&#8217;ve been reading through the 70 or so comments on our last 2 jQuery posts.&nbsp; There have been a lot of great questions.&nbsp; Apologies for not being able to answer them sooner (I was busy preparing for Dev Connections).&nbsp; Instead of answering them inline with the comments, I&#8217;ll try to paraphrase the popular issues here [&hellip;]<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/dotnet\/wp-json\/wp\/v2\/posts\/4004","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/devblogs.microsoft.com\/dotnet\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/devblogs.microsoft.com\/dotnet\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/dotnet\/wp-json\/wp\/v2\/users\/404"}],"replies":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/dotnet\/wp-json\/wp\/v2\/comments?post=4004"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/dotnet\/wp-json\/wp\/v2\/posts\/4004\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/dotnet\/wp-json\/wp\/v2\/media\/58792"}],"wp:attachment":[{"href":"https:\/\/devblogs.microsoft.com\/dotnet\/wp-json\/wp\/v2\/media?parent=4004"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/dotnet\/wp-json\/wp\/v2\/categories?post=4004"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/dotnet\/wp-json\/wp\/v2\/tags?post=4004"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}