数据注释验证错误消息立即显示。 EF 4.2/MVC3
即使控件中有数据,我所需的数据注释消息也会立即显示在编辑表单中,但我遇到了问题。如果我单击保存一切工作正常,如果我将焦点集中到显示错误的控件,然后将焦点更改到另一个控件,错误消息就会消失...这似乎只是我的编辑表单中的问题,而创建则不然没有同样的问题。
我将 EF 4.2 与 dbcontext 生成器结合使用,并通过元数据类使用验证数据注释。我的类使用metadataType 属性指向元数据类。下面的类:
<MetadataType(GetType(PersonsMetaData))>
Partial Public Class Persons
End Class
Public Class PersonsMetaData
Private mPersonFirstName As Object
Private mPersonLastName As Object
Private mPersonPrimaryEmail As Object
<Required()> _
Public Property PersonFirstName As Object
Get
Return mPersonFirstName
End Get
Set(value As Object)
mPersonFirstName = value
End Set
End Property
<Required()> _
Public Property PersonLastName As Object
Get
Return mPersonLastName
End Get
Set(value As Object)
mPersonLastName = value
End Set
End Property
<Required()> _
Public Property PersonPrimaryEmail As Object
Get
Return mPersonPrimaryEmail
End Get
Set(value As Object)
mPersonPrimaryEmail = value
End Set
End Property
End Class
我的编辑视图是使用 mvc 3 框架生成的。
任何建议将不胜感激
I'm having an issue with my required data annotations messages showing up right away in my edit form even though there is data in the controls. If I click save everything works fine and if I give focus to the controls that have the error displayed and then change focus to another control the error message goes away... This seems only to be the issue in my edit form, create doesn't have the same issue.
I'm using EF 4.2 with the dbcontext generator and using the validation data annotations via a metadata class. My class points to the metadata class using the metadataType attribute. class below:
<MetadataType(GetType(PersonsMetaData))>
Partial Public Class Persons
End Class
Public Class PersonsMetaData
Private mPersonFirstName As Object
Private mPersonLastName As Object
Private mPersonPrimaryEmail As Object
<Required()> _
Public Property PersonFirstName As Object
Get
Return mPersonFirstName
End Get
Set(value As Object)
mPersonFirstName = value
End Set
End Property
<Required()> _
Public Property PersonLastName As Object
Get
Return mPersonLastName
End Get
Set(value As Object)
mPersonLastName = value
End Set
End Property
<Required()> _
Public Property PersonPrimaryEmail As Object
Get
Return mPersonPrimaryEmail
End Get
Set(value As Object)
mPersonPrimaryEmail = value
End Set
End Property
End Class
My edit view has be generated using the mvc 3 framework.
Any advice would be appreciated
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论