ASP.NET IronPython

T4MVC now has a real home and a dedicated forum!
Up until now, most things related to T4MVC were happening through my various blog posts about it.  And while that was sort of working ok for a while, it was also less than ideal for a couple reasons. First, there was no single place to go to in order to get information about it.  You’d basically have to go through the various posts that describe the various features as they were added.  And as the number of posts grew, so did the pain involved in doing that. The second issue is that there was no good place to discuss it, ask questions and report issues.  So all of those things were mostly just happening organically as comments in my various posts, which really doesn’t work so well.  Blog Post comments don’t support threading...
T4MVC 2.5.01: added support for Html.RenderAction and Html.Action
To get the latest build of T4MVC: Go to download page on CodePlex   MVC 2 Beta introduces two nice helpers called Html.RenderAction and Html.Action.  Phil Haack described them in detail on his blog , so you may want to read through that before reading this post. Basically, they’re two additional methods that follow the standard MVC pattern of passing the controller name and action name as literal strings, and the action parameters as anonymous objects.  e.g. Copying from Phil’s example, if you have an Action like this: public ActionResult Menu(MenuOptions options) { return PartialView(options); } You can write this in your View: <%= Html.Action("Menu", new { options = new MenuOptions { Width=400, Height=500} })%>...
T4MVC 2.5.00 update: multiple output files and minified javascript support
To get the latest build of T4MVC: Go to download page on CodePlex   T4MVC build 2.5.00 brings a couple of fun new features that I’ll describe in this post.  I can’t take too much credit for them as they came from users who suggested them to me, and helped out getting the code going.   Support for multiple output files Up until now, T4MVC.tt has always generated a single file, which is the T4MVC.cs that you see get nested under it in VS.  And normally, this is the way T4 templates work: they just generate one file.  But last week I got an email from Stuart Leeks who pointed me to a new blog post from Damien Guard that describes a nice way to get around this description.  All of Damien’s logic is very nicely encapsulated...
Peter Blum’s new blog and his cool new data source controls
Peter Blum has been well known is the ASP.NET world for many years for writing a whole suite of powerful controls, which you can read all about on his site .  One thing that was missing on Peter’s resume is that he never had a blog.  Well he started one earlier this month, and is making up for the lost time in a big way, with already 11 posts!  And we’re not talking about small posts that just point to other people’s stuff (unlike this post I suppose!), but real with useful meaty content.  Make sure you check out his blog at http://weblogs.asp.net/peterblum/ .  I hope he keeps the good stuff coming! In particular, Peter has been working hard on some interesting data source controls that work with Visual Studio 2010. ...
Using C# Dynamic to simplify ADO.NET Data Access
Recently, I started playing around with C# dynamic, and blogged how it could be used to call static class members late bound .  Today, I was talking to Phil Haack , who I think had talked to ScottGu , and he mentioned that it would be cool to use dynamic to simplify data access when you work directly with SQL query.  So I thought I’d play around with that, and it didn’t take much code to make it work nicely. So the scenario is that you’re not using any fancy O/R mapper like LINQ to SQL or Entity Framework, but you’re directly using ADO.NET to execute raw SQL commands.  It’s not something that I would personally do, but there are a lot of folks who prefer this over the higher level data access layers. So let’s look at an example...
Using C# dynamic to call static members
By now, you’ve probably heard that C# 4.0 is adding support for the dynamic keyword, which introduces some aspects of dynamic languages to C#.  I had not had a chance to really try it, but recently I was reading Bertrand Le Roy’s post on the topic, and was sort of looking for a good opportunity to use it. Today, I found a scenario which I thought it would work great for, but it turned out not to be supported out of the box! The scenario is to call static class members using dynamic.  That probably sounds crazy, so let’s look at an example.  Say you have these two classes: public class Foo1 { public static string TransformString(string s) { return s.ToLower(); } public static string MyConstant { get { return "Constant from...
T4MVC 2.4.04 update: MVC 2 support, new settings, cleanup, fixes
To get the latest build of T4MVC: Go to download page on CodePlex   Though I haven’t blogged for a while about T4MVC, I’ve been making a few minor updates and only sent notification via Twitter.  Now, I have a few things that are worth discussing in a little more detail.  Note that you can see the complete list of changes from version to version in the readme.txt file that comes with it.  BTW, I used to have all this revision information directly in the .tt file, but it was getting a little long so I moved it to the readme. The changes described below were added between version 2.4.00 and 2.4.04.   MVC 2 Preview 2 support The most interesting things to many people is that I just made a fix to allow T4MVC to work on MVC...
T4MVC 2.4 updates: settings file, sub view folders, ActionName support and more
To get the latest build of T4MVC: Go to download page on CodePlex This post is a continuation of various previous posts on the T4MVC template for ASP.NET MVC: A new and improved ASP.NET MVC T4 template The MVC T4 template is now up on CodePlex T4MVC 2.2 update: Routing, Forms, DI container, fixes I last blogged about version 2.2, and there have been a number of changes since that (you can get the full history at the top of the T4MVC.tt file).  This post describes some of those changes.   T4MVC now uses a separate settings file Previously, if you wanted to customize T4MVC, you’d have to change T4MVC.tt directly.  This is fine until you want to grab the next build, and have to hand merge the changes. Instead, it is now using a separate...
Using an Associated Metadata Class outside Dynamic Data
A while back, I blogged about how ASP.NET Dynamic Data apps can uses an Associated Metadata class (aka a ‘buddy’ class) to add metadata attributed to properties defined in a generated class. It’s a mostly ugly thing that was made necessary by limitations of the C# and VB.NET languages: they don’t let you add attributes to properties defined in another partial class. What I didn’t mention there is that this ‘buddy’ class mechanism is actually not specific to Dynamic Data apps, and can in fact be used anywhere. Since I’ve recently heard of several cases of users trying to do something similar, I’ll describe how it’s done. If you’re familiar with TypeDescriptionProviders (which have been around since ancient times), this will look very trivial...
Two ways to use T4 templates: support code vs. one-time generation
T4 templates have proven to be useful is a whole range of scenarios, and more and more developers are finding interesting things to do with them. For the most part, all those scenarios fall under two very distinct categories: “support code” versus one-time generation.  Unlike my previous post on CodeDom vs. T4 , here we’re not talking about making a choice between two competing technologies, but simply about using T4 in the way that makes sense for a given scenario. Let’s start with a brief description of the two usage patterns: Support code : here, a T4 template generates a file that you rarely need to look at, and you should never modify.  Instead, it contains “support code” that you can code against.  A great example of this...
More Posts Next page »