带模板的 Silverlight 3 验证 DataForm
我有一个 SL3 应用程序,其中使用 DataForm 进行数据输入。 我希望我的表单看起来像我喜欢的那样,因此,我使用
并且在模板内我有漂亮的表单设计。
主要问题是,在模板内我必须使用普通控件(如 TextBox)而不是“字段”控件(如 DataFormTextField)。 它们的工作原理几乎相同,但在验证时却存在很大差异。
如果我在它们所绑定的属性的设置器中抛出异常,它们都会显示正确的红色符号和错误,但是如果我通过验证属性来装饰该属性(例如 [Required(ErrorMessage = "can'不能为空!")]
),只有 DataFormTextField 控件而不是 TextBox 控件会显示错误。 在这两种情况下,我的 ErrorSummary 控件在其集合中都有错误,因此我可以看到正在考虑该错误...
任何帮助都会受到赞赏。
I have a SL3 application in which I'm using DataForm for my data entry. I want my form to look in the way I like it, so, I use <dataControls:DataForm.EditTemplate>
and inside the template I have my good looking form design.
the main issue is, inside the template I have to use normal controls (like TextBox) instead of the "field" controls (like DataFormTextField). they both work almost the same with the big difference when it gets to validation.
if I throw an exception in the setter of the property to which they are bound, they both show the proper red sign and error, but if I decorate the property by validation attributes (for example [Required(ErrorMessage = "can't be empty!")]
), only the DataFormTextField control and not the TextBox control will show the error. in both cases my ErrorSummary control has the error in its collection, so I can see the error is being taken into account...
Any help is appreciated.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您使用模板字段吗?
Are you using the template field?