Tips, tricks and all the info about Microsoft Visual Studio 2008

A happy JavaScript-er with the new features of Visual Studio 2008

, posted: 5-Mar-2008 09:00

Okay, so I downloaded the Trial Edition of Visual Studio 2008 Team Suite two months ago. As one of the local speakers on the February Summer Road Trip I felt I needed to have a reasonable time of experience with the new version.
 
And even though I work on my own, I decided to download the Team Suite anyway. It was only 600 MB more. With the download speeds we have in Napier, who would notice the difference?

Now I am not someone who is always at the front of new technology. I have had the Visual Studio 2008 beta sitting on my laptop for months, but had hardly come to use it. How I now wish I had ...

The first task of course was to convert one of my web application projects from Visual Studio 2005 to Visual Studio 2008. That was a real breeze.

With built in multi target support for .NET 2.0, .NET 3.0 or .NET 3.5 based projects in your solution (you can even mix different target platforms in one solution), all Visual Studio 2008 did was convert my solution and project files and there I was, a couple of minutes later, ready to go.

Visual Studio 2008 has several big improvements:

   • New Design view, including a split view and CSS design tools.
   • Integrated support for AJAX.
   • Built in LINQ support and Object/Relational Designer.
   • JavaScript intellisense and debugging.

And more. Depending on your particular area of work, you will find many others. Have a look at "What's new in Visual Studio 2008" for more details.

Because I am currently working on a few websites where JavaScript is a rather important component, JavaScript was my first focus in starting to use VS08. And I was not disappointed! The new features in Visual Studio 2008 for JavaScript are:

   • Intellisense (isn’t that great, something we have been waiting for for a while).
   • Documentation support like in your C# or VB code.
   • Debugging (getting it all in one integrated environment is so much easier).

JavaScript Intellisense
Let’s start with the Intellisense feature: One of the first things you will see when you start adding JavaScript to your page is that you will be prompted with applicable keywords:




Continue on and you will see that the DOM methods defined on an object will pop up for you. No need any more to keep that JavaScript book open on your desk all the time.


Now of course JavaScript is not a strongly typed language, and Visual Studio 2008 does not go as far as to find out that the element I just retrieved by getElementById is a “Select” element.

But it does know that getElementById returns an HTMLElement and prompts you with all the HTMLElement methods. In fact it does type inference for variables depending on the value assigned to the variable and it will pop up the applicable methods for the inferred type. (Try assigning a string to the variable and you will see.)




When you go a bit further and you have your own functions defined, Visual Studio 2008 will also prompt you for those:



It even includes your function parameters:
 




All this also works when you have your functions sitting in a script file and you include the script in your web page. I created a script dates.js with a small variation of the CheckDate function like:




I can now include the dates.js script in my page and intellisense still works:




There is just one catch here: You should include the src path of your script as a relative path. An absolute path like src="/dates.js" mce_src="/dates.js" is not supported. And because of this I still have a bit of an issue with including scripts in master pages at the moment, but I am sure that will get sorted soon.

Documentation
The last thing to mention about the JavaScript intellisense is the support for .NET-like documentation. I added the following documentation to my dates.js script file for the CheckDateFromDDLs function. There is one thing to note here: you need to put the documentation inside the function body instead of above it.




Then when I get the intellisense popup again for this function, the documentation summary is displayed next to it:



As you would expect, the documentation for the parameters pops up as soon as you get to each parameter.

On top of that there is great support as that from AjaxDoc which will extract the documentation from your script file and turn it into a .NET XML documentation file you can turn into a help file with tools like Sandcastle.


Debugging
A final improvement I would like to discuss is the integrated JavaScript debugging. Visual Studio 2008 now has JavaScript debugging integrated in the IDE.

Exceptions at the JavaScript level are caught and you jump into the debugger, where you can examine variables, call stack etc. But just as easily, you put a breakpoint in your JavaScript code and in your server side code and (for instance when you are making an AJAX call) you just as happily jump from client side debugging to server side debugging and back. This was one of the demonstrations on the Summer Road Trip.

Debugging JavaScript works exactly as you expect it to.


 

The breakpoint set in this function shows that the ddlDay var is still null. That is because I mistyped the value of the “dayID” parameter on calling the function.


Finally
For me all these new features have had a huge productivity boost. I have one project still going where I have to use Visual Studio 2005, because one of the people I am working with is still on that version and swapping solution and project files is just too much of a hassle. But that is it for me. No turning back for this chap. Download the trial version as quickly as you can. The upgrade is painless and you will not be sorry.

Also note that the JavaScript functions created here are not meant to be an example of how to handle dates in your web forms or as good JavaScript coding. The code is only written as it is to conveniently show off the new VS08 features.

Download Visual Studio 2008 90 day trial
For detailed information and to request a free 90-day trial DVD of Visual Studio 2008 Team Suite to be sent out to you, go to the Microsoft Visual Studio webpage.

Gerard van de Ven



About the Author
Gerard has been a software developer for over 20 years. A lot of this time was spent with Philips Electronics in the Netherlands. Gerard also has 10 years experience of teaching Software Development at Bachelor Degree level, both in the Netherlands and in New Zealand.

Gerard arrived from the Netherlands in New Zealand almost five years ago together with his wife Elly and their two cats. They settled in Napier, where Gerard set up his own Software and Web Development business:
Birdwood Software Solutions. He specialises in developing highly interactive websites based on .NET and SQL Server technology, from small sites to websites with over 300 pages. Next to that he also has some clients for which he develops and maintains Windows applications based on .NET.
Gerard is also the coordinator of the Hawke’s Bay .NET User Group and the secretary of the New Zealand .NET User Group Inc Soc.


Other related posts:
The New Zealand ALM Conference 2011 (Application Life Cycle Management)
Writing your own Html Helpers for the ASP.NET MVC Framework
Automating Visual Studio 2008








Comment by Gerard van de Ven, on 5-Mar-2008 09:22

Just to add to my description above about problems I had with including JavaScript files in Master Pages. These problem are now solved thanks to some help from Jeff King, Program Manager for ASP.NET at Microsoft.

Jeff pointed out that the best way to include javascript files is by using the ScriptManager's capabilities. This allows you to specify the src path using the App-Root notation of "~". The ScriptManager will properly resolve this path and at the same time is it recognised by the path resolution engine used by Intellisense. So what I should have done is include my script as:

With the ScriptManager placed before any content place holders. And you can of course do this as well in "normal" (i.e. not Master) pages. For some more detail see the ASP.NET forum discussion http://forums.asp.net/p/1226715/2210208.aspx#2210208.

Thanks Jeff! It is great to see you guys responding to problems posted in these forums.


Comment by Gerard van de Ven, on 5-Mar-2008 09:27

I see the actual ScriptManager code did not make it to my comment. Might be filtered out because of the html tags. I'll try again. Replace the [ ] by the appropriate symbols, or just have a look at the forums discussion.

[asp:ScriptManager ID="ScriptManager1" runat="server"]

[Scripts]

[asp:ScriptReference Path="~/scripts/dates.js" /]

[/Scripts]

[/asp:ScriptManager]


Gerard


Comment by chiefie, on 5-Mar-2008 10:27

Wow!!! I have always use Dreamweaver for many of my web development. Admittedly, I have not done any .NET web development but I have recommended and heard more and more how useful and reusable to the code when making a project-based development.

Javascript (and AJAX) is quite powerful and fun and seeing that VS08 now support Intellisense for JS that's a great bonus! I might have to venture down this path to learn a bit more on using VS08 for web development. Though my work mixes between content and fair bit of development... So my next curious question is, how well is VS08 for template, design and content development when compare to Adobe Dreamweaver CS3?

Also, colour me green, does VS08 support PHP too?


Comment by Gerard van de Ven, on 6-Mar-2008 14:23

Hi chiefie,

I have only used Dreamweaver 8 sofar. So can't say much about Dreamweaver CS3. And certainly wouldn't claim to be an expert on Dreamweaver. My work is mostly development.

One thing that differs VS08 from Dreamweaver is that it is not meant for developing static websites. VS08 is really meant for building .NET Web Applications. Master Pages for instance are similar to DW templates, but require a .NET framework to run on.

But VS08 combines very well with Expression Web and you can download a trial version. This is the new "Dreamweaver" like tool from MS, it has exactly the same sort of dwt templates as Dreamweaver has, and they do not require a .NET framework.

Overall CSS support and the designer have greatly improved in VS08, with now also a split view, managing CSS directly in the environment etc. That is worth a blog in itself.

I am on the verge of leaving Dreamweaver behind and go to the Expression Suite for the design part of things. Especially if you are moving from Design, Layouting to coding a lot, the tight integration of these tools is the way to go. Try out Expression Web and let us know what you think.

And no, VS08 does not support PHP. Heaven forbid.

Cheers, Gerard


Comment by Gerard van de Ven, on 6-Mar-2008 14:27

Hi chiefie, I have only used Dreamweaver 8 sofar. So can't say much about Dreamweaver CS3. And certainly wouldn't claim to be an expert on Dreamweaver. My work is mostly development. One thing that differs VS08 from Dreamweaver is that it is not meant for developing static websites. VS08 is really meant for building .NET Web Applications. Master Pages for instance are similar to DW templates, but require a .NET framework to run on. But VS08 combines very well with Expression Web and you can download a trial version. (http://www.microsoft.com/products/info/product.aspx?view=22&pcid=7c653b63-095f-4e23-9da4-3c844e38fc88&crumb=catpage&catid=9d273393-92c9-4807-be9c-515a0d152415). This is the new "Dreamweaver" like tool from MS, it has exactly the same sort of dwt templates as Dreamweaver has, and they do not require a .NET framework. Overall CSS support and the designer have greatly improved in VS08, with now also a split view, managing CSS directly in the environment etc. That is worth a blog in itself. I am on the verge of leaving Dreamweaver behind and go to the Expression Suite for the design part of things. Especially if you are moving from Design, Layouting to coding a lot, the tight integration of these tools is the way to go. Try out Expression Web and let us know what you think. And no, VS08 does not support PHP. Heaven forbid. Cheers, Gerard


Comment by Sam, on 8-Mar-2008 14:15

Fortunately I haven't had to do much JavaScript yet, but Visual Studio 2008 will be useful if I need to. Also I like how you can press Control (?) and the Intellisense will become translucent.


About the Visual Studio 2008 Blog

In the years since the hugely successful release of Visual Studio 2005, Microsoft has used developer feedback from all over the world to introduce over 250 new features in the 2008 release.

This sponsored blog will bring Visual Studio 2008 tips and tricks from well known developers in the Australian and New Zealand tech community directly to you.

Make sure you bookmark this blog or subscribe to our RSS feed.



Other blog posts

The New Zealand ALM Conference...
Writing your own Html Helpers ...
Automating Visual Studio 2008...
Windows Azure Table Storage - ...
Windows Azure Table Storage - ...
XML and XSLT in Visual Studio ...
Introduction to New SQL Server...
Using the Visual Studio 2008 P...
Getting started with Windows A...
Why consider sitting for an MC...


Some recent comments

Praveen M on Visual Studio 2008 support for building SilverLigh: I installed SILVERLIGHT TOOLS for VS2008 at my work. I am able to do silverlight...

zefo on Unit testing with Visual Studio 2008: Just minor recommendation: better use *.png for the screenshots. Jpeg is more su...

gil ziny on Unit testing with Visual Studio 2008: When I associate the unit test with TFS testing policy, if fails during check-in...

lynette on Visual Studio 2008 JavaScript Debugging: i have enable in IE the ability to debug scripts. if i go to my section in my c...

Junkie on Why consider sitting for an MCTS or MCP Certificat: The way you presented the case for certification has been completely different f...

Brian Link on Unit testing with Visual Studio 2008: You seem to be incorrect in one of your opening remarks - it seems that web.conf...

Dipanwaya on Unit testing .Net Compact Framework applications w: Steps Behind the Test in the VS 2008? How to test a module in the VS 2008 Envir...

Ricardo on Visual Studio 2008 support for building SilverLigh: Yes! Found the solution myself :) Reset the environment of Visual Web Developer...

Ricardo on Visual Studio 2008 support for building SilverLigh: Have the same problem after installing Visual Web Developer 2008 SP1 and Silverl...

kjward on Automating Visual Studio 2008: thanks lots for all the great info. i'm sure the answer to my question is in th...



Disclaimer

The Visual Studio 2008 blog is sponsored by Microsoft NZ. The blog posts are the authors' genuine accounts of their experiences with Visual Studio 2008 and are not influenced or filtered by Microsoft NZ in any way.