Is the DataTypeAttribute validation working in MVC2?

后端 未结 5 1446
鱼传尺愫
鱼传尺愫 2020-12-03 07:26

As far as I know the System.ComponentModel.DataAnnotations.DataTypeAttribute not works in model validation in MVC v1. For example,

public class Model
{
  [Da         


        
5条回答
  •  青春惊慌失措
    2020-12-03 08:03

    Like LukLed pointed out, DataTypeAttribute doesn't do any validation by default. But it does influence templates regarding how the data is presented.

    For example if you call Html.DisplayFor() method on a model that has DataType(DataType.EmailAddress) attribute, it'll format its value with {0} (at least in MVC RC2).

提交回复
热议问题