在ASP.NET MVC 3中DataAnnotations的行为是否已更改? [英] Has the behavior for DataAnnotations in asp.net mvc 3 changed?

查看:69
本文介绍了在ASP.NET MVC 3中DataAnnotations的行为是否已更改?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个带有属性的模型

I have a Model with a property

[ReadOnly(true)]
public decimal BodyMassIndex { get; private set; }

致电时在我的视野中

@Html.EditorForModel()

我仍然可以看到该属性的标准可编辑文本框

I still get a standard editable textbox for that property

这是为什么?如果文本框仍可编辑,则此DataAnnotation属性的意义是什么?

Why is this? if the textbox is still editable whats the point of this DataAnnotation Attibute?

布拉德·威尔逊的帖子

推荐答案

这不是DataAnnotation属性.请注意,它位于 System.ComponentModel 名称空间中.数据注释位于 System.ComponentModel.DataAnnotations 名称空间中.

That is not a DataAnnotation attribute. Notice it's in the System.ComponentModel namespace. Data Annotations are in the System.ComponentModel.DataAnnotations namespace.

但是,在这种情况下,我们可以考虑支持它.但是,您究竟期望发生什么?为什么要这么做?

However, this is a case where we could consider supporting it. But what exactly did you expect to happen and why do you want this?

这篇关于在ASP.NET MVC 3中DataAnnotations的行为是否已更改?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆