Free Microsoft AJAX Templates for CodeSmith + Overview Video
Posted in Development
Here’s something I wanted to do for a long time. The Microsoft AJAX library brings order to the chaos of JavaScript development by introducing familiar concepts: namespaces, classes, interfaces, enumerations, property setters and getters, etc. The downside is the laborious and error-prone manual coding of all that goodness.
My first impulse was to write JavaScript snippets for Visual Studio 2008. After two hours of fiddling, it seemed Visual Studio wouldn’t budge. Then I saw Jeff King’s comment on ScottGu’s blog that they won’t be supported in VS 2008. Bummer. They would’ve been awfully handy.

Given the popularity of CodeSmith and its templating markup language I decided to give it a try. Eventually I put together a set of templates which code-gen the following:
- enumerations, interfaces and classes
- non-visual components (
Sys.Component) - client
controls (
Sys.UI.Control) - behavior controls (
Sys.UI.Behavior)
To produce these templates, I’ve gone through the official docs from A to Z, as well as bevy of samples found on blogs. I was looking for common patterns of implementation, so the templates represent my best shot.
For example, in an event handler of a behavior control you will probably manipulate the associated element. In a client control you will probably allow the caller to add their own event handlers, so you won’t need to manipulate the associated element yourself. These are general cases, and you certainly don’t have to follow them by the book, but that’s the kind of boilerplate code the templates generate.
Links
Download templates and watch the video (safe for work; no dancing strippers, I promise) from the CodeSmith Gallery.
Acknowledgements
I’d like to thank Eric Smith’s crew for a free license of CodeSmith. Learning its markup language is a breeze and there are plenty of templates “out of the box” and up on the web site.
Also, big thanks to TechSmith for a free license of Camtasia which allowed me to put together the screencast. It’s amazing what this product can do!
6 comments
Michael
on December 20, 2007
Thank you very much for creating the templates. They are really useful.
CodeSmith is such a mighty tool. I don't want to think about the time before I've got to know about CodeSmith, I just wasted so much time...
mansour
on March 11, 2009
cool
Hatem
on September 4, 2009
I didn't use codesmith before , I would like to use , Can anybody help me ?
by Video or Website explaine how it works
Milan Negovan
on September 4, 2009
Hatem, please refer to their site. They have a video tutorial there.
shakti
on May 5, 2010
If you find a bug in the CSLA templates, its a huge help to the community and us if you submit a failing unit test for the PetShop sample application that can reproduce your bug. This ensures we have more testability and no regressions in future versions. However, any unit test will be appreciated along with the respected sample schema.

Miha Markic
on November 29, 2007
You can also embed that stuff right into VS by using CS code generator or CS active snippets. CodeSmith is such a great timesaver.
Anyway, thanks for the templates :-)