详细信息视图中的自定义验证器
有谁知道如何使 CustomValidator 与 DetailsView 中的控件一起使用,例如更新项目
CustomValidator 不适用于在执行详细信息视图更新后在DetailsView 中的控件。例如,RequiredFiledValidator 工作没有问题,而 CustomValidator 有问题(验证不发生):/
Does anyone know how to make CustomValidator work with controls which are in DetailsView for example ahen updating item
CustomValidator doesnt work on controls which are in detailsView after performin for example update on that detailsView. For example RequiredFiledValidator works with no problem while CustomValidator has problems (Validation doesnt occur):/
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
问题在于,DetailsView 中的更新链接不会触发回发中的验证控件,因为需要使用 Button、ImageButton 或 LinkButton 才能发生这种情况。使用 JavaScript 的客户端验证器也可以工作,尽管这相当令人困惑。
解决方案是将您的DetailsView:s CommandField 转换为TemplateField:“编辑字段”->选择命令字段 ->单击“将此字段转换为 TemplateField”。
您可以在此处查看有关此问题的讨论: http://forums.asp.net/t /1102008.aspx?PageIndex
The problem is that the update link in the DetailsView does not trigger validation controls in the postback since a Button, ImageButton or LinkButton is required for this to happen. Client-side validators that are using javascript will work though which is pretty confusing.
The solution is to convert your DetailsView:s CommandField to a TemplateField: 'Edit Fields' -> Select the Command Field -> click 'Convert this field into a TemplateField'.
You can see a discussion about this here: http://forums.asp.net/t/1102008.aspx?PageIndex