I don’t know about you but I’m a big fan of intellisense and for a while I’ve been using a simple hack to get javascript intellisense working. For example, I’ve just added the following lines to the master page :
<%-- A simple hack to fool Visual Studio into giving us intellisence for javascript --%> <%if(false) {%><script type="text/javascript" language="javascript" src="ClientResources/Javascript/uitools.js"></script><%}%> <%if(false) {%><script type="text/javascript" language="javascript" src="ClientResources/Javascript/jquery-1.3.2-vsdoc.js"></script><%}%> <%if(false) {%><script type="text/javascript" language="javascript" src="/../lib/jqueryplugins/jquery.rms.ajaxprogress.js"></script><%}%> <%if(false) {%><script type="text/javascript" language="javascript" src="/../lib/jqueryplugins/jquery.rms.ajaxhistory.js"></script><%}%>
There are a few things to note :
- The if (false) is the neat little hack that means this will never get rendered but Visual Studio will still parse and provide intellisense for the references.
- I’m including the jQuery using the vsdoc version which means the intellisense as slightly more information in it. For example :
- To extend our own javascript files with vsdoc info see Scott Guthries blog – it’s just a case of formatting the javascript comments.
- You can also use parents paths out of the web site and into the lib folder!
- This will also work with style sheets which means the underlining of styles telling you they don’t exist goes away! Admittedly you have to pick either a default one or a customer stylesheet but that’s better than nothing!
<%if(false){%><link href="../styles/Styles.css" rel="Stylesheet" type="text/css" /><%} /* Weird trick to resolve css references in the page without affecting compiled output */%>
