Click here to Skip to main content
15,886,806 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hello Guys!
I've just begun working with JS in VS2013 premium. No problems about coding, but I think I'm missing something.

Intellisense doesn't show all of the methods I'd expect.

To clarify.. I have a reference to an external js file that loads an XMLDoc.

Then I try to traverse the XML using the method GetElementsByTagName, but Intellisense show me only a few things.

This is what I've done:
ASP.NET
<%@ Master Language="C#" AutoEventWireup="true" CodeBehind="Prova.Master.cs" Inherits="FTBL.FTBL" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">

<head runat="server">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <title>FTBL Tips Homepage</title>
    <script src="Scripts/JavaScript/Script.js"></script>
 
    <asp:ContentPlaceHolder ID="Head" runat="server">
    </asp:ContentPlaceHolder>
</head>

<body>
  <form> 
    <div id="footer">
      <script type="text/javascript">
        var xmlDoc = loadXMLDoc("DataSources/XML/XMLCountries.XML");
        x = xmlDoc.GetElementsByTagName("Country")[0];
        y = x.childNodes[0];
        document.write(y.nodeValue);
    </script>
    </div>
  </form>
</body>
</html>

The only things that intellisense shows me are:

constructor, hasOwnProperty, isPrototypeOf, propertyIsEnumerable, toLocalString, toString and valueOf

Any suggestion?

Many thx!
Posted
Updated 10-May-14 22:34pm
v2
Comments
Kornfeld Eliyahu Peter 11-May-14 4:39am    
You may try and add a XML-like reference at the top of your page...<br>
/// <reference path="Scripts/JavaScript/Script.js"></reference>
leotato008 11-May-14 5:37am    
Thx Kornfeld and Manas for your help. If I try to add the reference at the top of the masterpage the compiler says that element is not valid.<br>
Exactly, where do I have to put this reference you're talking about? The only place I can think of is the js file, but it makes no sense, doesn't it?
@Manas: I've had already read the article you suggested me.<br>
Anyway, isn't getElementsByTagName a standard method of the XML DOM? I expected it to be available by default in VS Intellisense.
Kornfeld Eliyahu Peter 11-May-14 5:48am    
Just spotted something...
I do not know if it has any connection but you have GetElementsByTagName with a capital G! That should be getElementsByTagName...
leotato008 11-May-14 6:00am    
Just a typing mistake.. I've also tried to add the path reference for the project using the project properties but nothing changed.. WTH! :-(
Kornfeld Eliyahu Peter 11-May-14 6:00am    
I made a lot of test to understand it, and I thin I have a kind of answer for you.<br>
The problem is that loadXMLDoc is a function that probably not all paths of it returns value...The default return value for that is undefined, so xmlDoc is interpreted as undefined... in which case intellisense will list all the names he grab from the current source...

1 solution

Did you try Reference Directives?

Quote:
A reference directive enables Visual Studio to establish a relationship between the script you are currently editing and other scripts. The reference directive lets you include a script file in the scripting context of the current script file. This enables IntelliSense to reference externally defined functions, types, and fields as you code.


http://msdn.microsoft.com/en-us/library/bb385682.aspx[^]

However, there are limitations to JavaScript intellisense when it comes to external references.

http://stackoverflow.com/questions/20569173/enabling-javascript-intellisense-for-external-libraries-in-visual-studio[^]

Why not use Typescript [^]? It's quite cool actually :)
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900