Saturday, December 21, 2013

Using HTML5 Helpers in ASP.NET MVC

If you are working with ASP.NET MVC, even with the new HTML5 Data Annotations, you may be able to get controls such as the Telephone and Email Input controls to render as their appropriate types, but the additional attributes that you may want to attach to that control may still not render (such as the "placeholder" attribute).

Fortunately, however, there is a workaround solution that addresses these deficiencies in the native MVC Framework.

This can easily be addressed through a NuGet package which includes HTML Helpers specific for HTML5.

This can be added directly through NuGet in Visual Studio by selecting the MVC5HtmlToolkit depicted in the screenshot below:


Once you have installed this NuGet package, you will then have the ability to use @Html.Html5EditorFor templates which will allow you to inject additional HTML5-specific attributes into your MVC forms!



No comments:

Post a Comment