Jul 29

In April I did a comprehensive blog post about the Html.EditorFor() and Html.DisplayFor() helpers in MVC 2, and there use with templates. It turns out I missed quite a cool feature added in the MVC 2 RTM release in March.

Taken from the release notes:

ASP.NET MVC 2 now includes new overloads of the EditorFor and DisplayFor methods. These overloads contain a parameter that accepts an anonymous object that can be used to provide extra view data. The view data provided in this parameter is merged with any existing view data that is passed to the template.

This new overload is very handy for providing additional information to your template without any nasty hacks. In this post we are going to continue our Employee example from my MVC Templates and MVC Model Binders posts, we will change the code to make use of the new overload.

Continue reading »

Tagged with:
May 21

In the last section of my MVC Templates post, I discussed how to use the Html.EditorFor() helper with complex types. Whilst this showed how you can use Html.EditorFor() and templates to produce a user interface for complex types, it didn’t show you how to bind the result when the user has posted to a controllers action. In this post I will extend the employee example, so that it displays the offices the the user selected.

Continue reading »

Tagged with:
Apr 26

MVC 2 is official, I’ve been using it for a while now (since preview), my favorite feature by far is templating. I’ve been using the templating feature extensively to upgrade an existing production application, in particular some quite ugly views.

Before templates to create a reusable UI, you really only had the options of user controls or writing your own Html helpers, the former will almost certainly mean a compromise. I believe the templating feature will assist in the goals of separation of concerns and being DRY.
Continue reading »

Tagged with:
Mar 12

MVC 2 is officially released, there are so many excellent features,  but the best feature for me is the strongly typed Html helpers. I’ve been playing around with this feature and will share some of my experiences with you.

http://weblogs.asp.net/scottgu/archive/2010/03/11/asp-net-mvc-2-released.aspx

Tagged with:
Feb 06

Generally bug fixes and performance enhancements.

One cool addition for me, is the HTML input helpers supporting array/collection indexes, for example: Html.EditorFor(foo=>foo.bar[i]) . I was working around this limitation using Html.EditorFor((foo)=>foo.bar[i], “Bar”) i.e. passing a function expression, but this means you have to pass a template name (to get the correct HtmlFieldPrefix), this addition means cleaner code and no hard references to templates, thanks MVC team.

Another notable change is Query 1.4.1, is now included by default with ASP.NET MVC 2 projects.

More info @ScottGu’s blog: http://weblogs.asp.net/scottgu/archive/2010/02/05/asp-net-mvc-2-release-candidate-2-now-available.aspx

Tagged with:
preload preload preload