The DataType attribute in the context of ASP.NET MVC more or less represents a hint of which view template to use to display the display and editor for this property. As you noticed, it provides an enumeration of the supported data types for which ASP.NET MVC internally provides an editor and display templates (MultilineText โ textarea html input), but can also accept a string parameter with a name of a user type. All he does is search with that name (predefined or missing) in Views/ControllerName/EditorTemplates/{DataTypeName}.cshtml or Views/ControllerName/DisplayTemplates/{DataTypeName}.cshtml when you use the editor / editor for screen or Display / DisplayFor respectively (it will also search in Views / Shared / ...). If it does not fit, it uses the built-in if it is available.
The effect of applying the DataType attribute DataType almost the same as if it were using the UIHint attribute, but it is somewhat more explicit. For example, I would use DataType.Currency for the price and UIHint user interface in the ui user slider.
Regarding verification, the built-in templates provide it, but if you have to use your own data type in your custom display / editor template, you have to provide it yourself.
source share