Wednesday, August 6, 2014

Writing JavaScript with Regions in Visual Studio

If you have a lot of JavaScript in your web application (most modern web applications do nowadays), then you probably have at least thought once or twice about how it would be nice to have regions in JavaScript just like there are in C#.

Well, fortunately, now you can have just that!

Using the Web Essentials extension for Visual Studio, you can define JavaScript regions that you can then subsequently expand and collapse while you are working with various sections of your JavaScript code: http://vswebessentials.com/features/javascript

You simply define your JavaScript regions like so:

//#region MyJavaScript Region
 
//#endregion


That is all there is to it!!

 

With the extension installed, Visual Studio will then recognize your JavaScript blocks as regions just as the regions are recognized in C#.

You can download Web Essentials for Visual Studio from here: http://vswebessentials.com/download

2 comments:

  1. Check CodeHelper Extension it does what you need, http://www.bluemusa.com/codehelper there is a youtube tutorial at
    https://www.youtube.com/watch?v=oc4IzAegMRk

    ReplyDelete
  2. Check CodeHelper Extension it does what you need, http://www.bluemusa.com/codehelper there is a youtube tutorial at
    https://www.youtube.com/watch?v=oc4IzAegMRk

    ReplyDelete