Recipe: How to make use of intellisense feature when coding JavaScript in Visual Studio 2010

Motivation

You have included a JavaScript library and you want to make use of intellisense while coding JavaScript in Visual Studio but you couldn’t find the correct way for it.

Recipe

Ingredients

  • 1 JavaScript library to include (i.e. jslinq.js)
  • 1 -vsdoc.js file of library you want to include (i.e. jslinq-vsdoc.js)

Directions

  • Include the -vsdoc.js file. You don’t need to include it in the same folder where your actual .js file is located.  However, it is more practical to keep them as close as possible for the ease of maintenance, code navigation and delightful presentation 🙂

image

  • Put the following code at the top of the JavaScript file (i.e. map.js) where you call functions of the included library (i.e. JSLINQ.js).
/// <reference path="~/Scripts/jslinq/JSLINQ-vsdoc.js" />

Tip of the recipe

    • This “<reference … /> codes” must be the first code in you calling JavaScript file (i.e. map.js)
    • The referenced path must be the path of –vsdoc.js file. Not the path of the actual js file !

 

  • Create an object of the library.

image

Tip of the recipe

  • If you create in the wrong way, although you can still use the object as expected, the intellisense won’t work.
  • Now you can make use of intellisense while you code JavaScript.

image

  • That’s it enjoy your code 🙂

How to maintain multiple configuration files for multiple deployment environment?

This used to be one of the most challenging issue that the majority of the developers come across when to deploy their application into a variety of environments such as development, test(or staging) and production.  The problem increases linearly if the application is to be deployed to multiple customers since each of them may be expected to have their own development, test and production environments.

Visual Studio 2010 provides a lean solution , namely Web.Config Transformations, for this sticky problem.  Below are simple tutorials about how to apply the solution.

http://msdn.microsoft.com/en-us/gg454290

http://msdn.microsoft.com/en-us/vstudio/ff801895

Edit: It is possible now to apply configuration file transformation even for console applications with the following free extension that has recently been released.

http://visualstudiogallery.msdn.microsoft.com/579d3a78-3bdd-497c-bc21-aa6e6abbc859

image