Skip navigation.

The Strategy for Discoverers and EntrepreneursAll recent postsMonopoly: C# 3.0 Edition

Free Microsoft AJAX Templates for CodeSmith + Overview Video

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.

CodeSmith with Microsoft AJAX templates

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:

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!

Comments

Comment permalink 1 Miha Markic |
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 :-)
Comment permalink 2 Michael |
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...
Comment permalink 3 mansour |
cool

Emails and Notifications

Would you like to be notified when somebody responds to this post?  Would you like to have these comments emailed to you?

Submit your comment

Please enter only text since all HTML tags except hyperlinks will be stripped. Hyperlinks will become live links. Any comments with flaming or offensive language will be deleted. Be courteous to other posters. Thank you.

Your name (required):
Your email (optional):
Your site's URL (optional):
Enter this number
Type in the number above:
Comment (required):