Tuesday, April 13, 2010

JS editing in VS 2008

When you have JavaScript in an .aspx file Visual Studio 2008 will list all of the functions in a drop down at the top of a page. However once you move the JS to a separate file VS suddenly loses this ability. You can trick it into regaining this feature with the following steps.

In the .js file add the following to the top and bottom of the file:
//<html xmlns="http://www.w3.org/1999/xhtml"><head><title></title><script type="text/javascript">
…
//</script></head><body></body></html>

And then in Tools -> Options -> File Extentions map js to the HTML editor: