将 ValidationSummary 限制为特定按钮
我有一个场景,我正在使用新添加的 ValidationSummary 控件。 我正在处理的表单有多个按钮(客户搜索、提交等)。 是否可以仅在用户单击提交按钮(而不是客户搜索按钮)时触发 ValidationSummary?
I have a scenario where I'm using a newly added ValidationSummary control. The form that I am working on has multiple buttons (customer search, submit, etc). Is it possible to fire the ValidationSummary only when the user clicks the submit button, as opposed to the customer search button?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
在客户搜索按钮上,添加“CausesValidation='False'”
On the Customer Search button, add "CausesValidation='False'"
执行此操作的最佳且最通用的方法是为摘要和所有要验证的控件以及提交按钮的 ValidationGroup 属性分配一个值。 只有具有相同 ValidationGroup 的控件才会受到影响。
使用验证组,您可以对页面的不同部分进行验证,而不会相互影响。 应大众需求,ASP.NET 2.0 中引入了此功能。
The best and most general way to do this is to assign a value to the
ValidationGroup
property for the summary and all the controls which are to be validated, as well as the submit button. Only controls with the same ValidationGroup are affected.Using validation groups, you can have different parts of a page validate without affecting each other. This feature was introduced with ASP.NET 2.0 by popular demand.