EF-> RIA 服务 -> Silverlight,我可以显示验证错误消息但仍保存更改吗
我正在使用 Entity Framework 4.0、RIA 服务和 Silverlight 4.0。我需要用户能够保存任何更改,无论它们是正确还是不完整。为此,我必须将数据库中的许多字段设置为可为空。我仍然希望能够在 Silverlight 客户端中向用户显示验证错误消息。我想做的是使用 DataAnnotations 来归属 Ria Services 中的实体元数据,以在客户端上获取良好的验证错误消息,但我需要用户能够保存,即使它破坏了验证。这可能吗?我将如何实施这个?
谢谢, 埃文
I am using Entity Framework 4.0, RIA Services, and Silverlight 4.0. I need the user to be able to save any changes regardless if they are correct or incomplete. To do this I had to make a lot of fields in the database nullable. I still want to be able to show validation error messages in the Silverlight client to the user. What I would like to do is use DataAnnotations to attribute the entities metadata in Ria Services to get the nice validation error messages on the client but I need the user to be able to save even if it breaks validation. Is this possible? How would I go about implementing this?
Thanks,
Evan
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
在 Silverlight 中,不存在仅警告数据注释验证器之类的东西。在 ASP.NET 中,您可以使用简单的客户端 JavaScript 的 CustomValidator 获得预期结果,但 Silverlight 中不存在此类等效项。最好的选择是将此逻辑编程到表单本身中,或者创建一个自定义控件,该控件允许您以 ToolTipService 的工作方式来装饰现有控件。
In Silverlight there is no such thing as warnings-only Data Annotation Validators. In ASP.NET you could get your intended outcome using a CustomValidator that was simply client-side JavaScript, but no such equivalent is present in Silverlight. Your best bet is to program this logic into the form itself or create a custom control which allows you to decorate an existing control much in the way that the ToolTipService works.