MVC 2 Editor Template with DateTime

One of the cool new features of MVC 2 is the ability to automatically pick an editor template based on the meta data of each property. This meta data can be as simple as the data type of the property itself.  Take an example where we have a Contact object that has a DateTime? property for DateOfBirth. public partial class Contact { [DisplayName("First Name")] public string FirstName { get; set; }   [DisplayName("Last Name")] public string LastName { get; set; }   [DisplayNa...


.NET 4.0 and Visual Studio 2010 Presentation at Microsoft

On February 4th, I will be presenting .NET 4.0 and Visual Studio 2010 at the Microsoft office in Reston [http://www.microsoft.com/About/CompanyInformation/usaoffices/midatlantic/mtc_reston.mspx] as part of my company's [http://www.appliedis.com/] continued efforts to provide education on Microsoft technologies. This presentation will cover a wide breadth of technologies that are being launched by Microsoft this year. The presentation is geared towards technical decision makers including Arch...


Encapsulate Multiple HTML Helpers to Make Views More DRY

MVC 2 is adding many new features that make views more elegant to write. For example, the new EditorFor() [http://msdn.microsoft.com/en-us/library/ee402949(VS.100).aspx] Html helper returns the appropriate HTML input elements for a given property so you don't have to explicitly specify text box, dropdown, or whatever control you need and can even use the [UIHint [http://msdn.microsoft.com/en-us/library/system.componentmodel.dataannotations.uihintattribute.aspx] ] attribute to specify the editor...


Implementing a Delete Link with MVC 2 and HttpMethodOverride

A while back I blogged about creating an MVC Delete Link with the AjaxHelper [http://geekswithblogs.net/michelotti/archive/2009/04/06/mvc-deletelink-with-ajaxhelper.aspx] . This was based on another blog post from Stephen Walther where he explained the drawbacks of using hyperlinks for delete scenarios [http://stephenwalther.com/blog/archive/2009/01/21/asp.net-mvc-tip-46-ndash-donrsquot-use-delete-links-because.aspx] .  HTTP and REST best practices state that GET requests should never modify a r...


LINQ to XML with Hierarchical XML, Optional Elements, and Namespaces

Recently I had an interesting task to consume a particular XML document and populate a C# object from it.  The structure of the XML document looked roughly like this: <root xmlns="http://www.w3.org/2005/Atom"> <entry> <id>1</id> <title>abc</title> <content> <div xmlns="http://www.w3.org/1999/xhtml"> <table> <tr> <td>Item1</td> <td>111</td> </tr> <tr> <td>Item2</td> <td>222</td> <...