I always like to use helper methods, and the ASP.NET MVC HtmlHelper methods are great. But sometimes you need some extra logic that they don't provide... Enter custom extension methods. Here is a class I wrote specifically for extension methods ( Note: Some of the extension methods are calling some static Utility methods, and their implementation is not shown here ): 01: public static class HtmlHelperExtensions { 02: 03: public static string DateFormatterTextBox( this HtmlHelper htmlHelper, string name, 04: DateTime date, string format, object attributes) { 05: string val = string .Format(format, date); 06: if (date.Year == 1900) 07: val = "0000-00-00" ; 08: return htmlHelper.TextBox(name, val, attributes); 09: } 10: public static string DateFormatterTextBox( this HtmlHelper htmlHelper, string name, 11: DateTime date, string format) { 12: strin...
...do yourself a favor and go somewhere else...