The first blog post I ever wrote was titled “ Turning an ascx user control into a redistributable custom control ”. It was almost exactly five years ago, and it still gets a lot of hits today. And interestingly, this new blog post is about solving essentially the same problem, but with a much nicer Razor based solution than was available at the time. The general issue we’re trying to solve is to encapsulate reusable pieces of UI. Unfortunately, this has typically meant choosing between two approaches, each having their pros and cons (this mirrors the intro from my old post): Custom code in a library project: this makes it easy to produce a binary that can be used in multiple projects without having to keep source files around...
Wow, it’s hard to believe that it’s been less than a week since NuPack went public. We were hoping to get noticed, but the attention we got was way beyond my wildest expectations! The buzz on Twitter has just been phenomenal, and for the most part the feedback has been very positive. Thank you all for that, this is very encouraging for our little NuPack team :) NuPack as a noun for the packages Before I get into the meat, I’ll just say that I want to start using NuPack as a noun that refers to the packages. So rather than saying “There is a NuPack package for Spark”, I’ll say “There is a NuPack for Spark”. Or to use NuPack teammate Rob Reynold’s catch phrase. “ There a NuPack for that! ”. Hmmm...
I just pushed T4MVC out to the MvcContrib CodePlex site. You can go to the T4MVC Home Page to get started with it. Last time I blogged about a T4MVC release was for 2.6.13. In the mean time, I released 2.6.14 and 2.6.15, but they were minor updates so I just tweeted them. You can check out the history page to see what they changed. Now, 2.5.20 brings a more interesting new feature, so I figured I’d blog it. New feature to easily render Partials Update (7/20/2010) : there was a small issue with this change when multiple ascx have the same name. I just pushed a new 2.6.21 build which addresses it. This new feature was written by Evan Nagle (who is also the author of the Chirpy add-in I discussed a few days...
Just a quick post to point folks to a very cool CodePlex Add-In that you may not know about. It’s called Chirpy and can be downloaded from http://chirpy.codeplex.com/ . The reason I discovered it is that it includes functionality to automatically run T4MVC. In fact, it is basically the new version of the Add-In by Wayne Brantley that I blogged about a few months back. Wayne has been working on this with Evan Nagle , who is the main owner. But note that Chirpy does a lot more than just run T4MVC automatically! Check out Evan’s post for a complete tutorial. To give a really quick intro, Chirpy makes it really easy to automatically: Minify your JavaScript files, using a selction of popular engines like YUI and...
Today, we announced the public availability of the Microsoft WebMatrix Beta . This is an exciting time, as we’ve been working on this project for quite a while, and have been eager to get it out there! Our VP Scott Guthrie has been blogging about a number of its components in the last week or so, and you should definitely read through his posts to get a lot of information about it (start here ). In this post, I’d like to discuss how various pieces fit together, as I’ve seen some amount of confusion in the early user comments that I have read. Note that I’m not going to describe the pieces in much details (again, see ScottGu’s blog for this). Instead, my focus is on clarifying the relationship between some of the...
Last week, I blogged about a nice way of auto-running T4MVC by using the Macro IDE to write an OnBuildBegin event handler . This was a big improvement over the hacky ‘AlwaysKeepTemplateDirty’ flag that we’ve been using since T4MVC’s early days. Since then, Wayne Brantley has taken this idea to the next level by turning it into a Visual Studio AddIn. Check out his post and give it a try! The nice benefits of the AddIn over directly handling VS events in the macro IDE are: Simpler install : you drop a couple files in the AddIn folder and it just works Encapsulation : all the code related to this is in one binary Easy to disable : once the AddIn is installed, you can just go in Tools / AddIn Manager to turn it on or off Note that Wayne...
T4MVC has always struggled with finding the right way of running automatically when you build. Being a T4 template in your project, by default it just runs when you save it. This is not great, because you really want it to rerun whenever you make a change that affects it: e.g. new controller action, new static file, … So I had come up with a pretty crazy workaround (the AlwaysKeepTemplateDirty flag), described in details in this previous post (under “ The T4 file automatically runs whenever you build ”). It’s a pretty hacky technique, which mostly works but has some nasty quirks: You need to open and save it once to start the save ‘cycle’ You need to leave it open It’s always marked as dirty, which is an annoyance. The...
To get the latest build of T4MVC: Go to MvcContrib T4MVC page on CodePlex A few weeks back, we announced (mostly on Twitter) that T4MVC was moving into the MvcContrib Codeplex project. I didn’t say much about it at the time because there wasn’t a whole lot to say yet, in the sense that the move had not actually happened. MvcContrib was transitioning from github to Mercurial, and since I wasn’t familiar with either one, I figured I’d wait for that and only have to learn Mercurial. So to make it short, all of this has finally happen, and we can now say that T4MVC is officially part of MvcContrib! Many thanks to Eric Hexter and Jeremy Skinner for helping make this possible. So what difference does it make for it...
This post applies to any ASP.NET app that uses .aspx files, whether WebForms or MVC. When you write an aspx/ascx/master file (I’ll just say aspx for here on, but it applies to all), it gets compiled dynamically by the ASP.NET runtime. Note that this is true whether you use a Web Site or a Web Application Project (WAP). While in a WAP, most of the code is built by Visual Studio, the aspx pages themselves are always built dynamically . Normally, when you work with aspx files, you only need to worry about what you write in there, and the specifics of what ASP.NET generates under the cover are somewhat of an implementation details. However, in some cases it’s pretty useful to look at the generated code, either to learn exactly...
Note: this is based on ASP.NET MVC 2 RC , and will not work on earlier builds. The quick pitch: make your User Controls as cool as built-in render helpers! The goal of this post is to show you how to change the way MVC user controls are called from something like this: <%= Html.Partial("~/Views/Shared/gravatar.ascx", new { Email = "foo@bar.com", Size = 80 }) %> To something that looks just like a built-in render helper (like Html.TextBox(…)): <%= Html.Gravatar("foo@bar.com", 80) %> The current model for User Controls in MVC If you have used ASP.NET MVC, you probably know that you can use User Controls (.ascx files) to provide partial rendering. For example, the default MVC app has a Site...
More Posts
Next page »