Html attributes for EditorFor() in ASP.NET MVC

Update MVC 5.1 now supports the below approach directly, so it works for built in editor too. http://www.asp.net/mvc/overview/releases/mvc51-release-notes#new-features (It’s either a case of Great mind thinking alike or they read my answer 🙂 End Update If your using your own editor template or with MVC 5.1 which now supports the below approach directly for built … Read more

MVC4 DataType.Date EditorFor won’t display date value in Chrome, fine in Internet Explorer

When you decorate a model property with [DataType(DataType.Date)] the default template in ASP.NET MVC 4 generates an input field of type=”date”: <input class=”text-box single-line” data-val=”true” data-val-date=”The field EstPurchaseDate must be a date.” id=”EstPurchaseDate” name=”EstPurchaseDate” type=”date” value=”9/28/2012″ /> Browsers that support HTML5 such Google Chrome render this input field with a date picker. In order to … Read more