页面上有多个RequiredFieldValidators,但它们需要应用于不同的按钮点击
我正在开发一个 asp.net 页面,并且有以下场景:
我有 2 个具有 requiredfieldvalidators 的字段,这些字段需要在单击“button1”时“触发”验证,但在单击“button2”时则不需要“触发”验证,另一个字段由另一个字段验证requiredfieldvalidator 与相反的场景。 (此字段的 requiredfieldvalidator 需要在单击“button2”时“触发”,但在单击“button1”时则不需要。)任何有关最简单解决方案的建议将不胜感激。
提前致谢
I'm working on a asp.net page and I have the following scenario:
I have 2 fields that have requiredfieldvalidators which need to "fire" their validation when button1 is clicked but NOT when button2 is clicked and another field which is validated by another requiredfieldvalidator with the opposite scenario. (requiredfieldvalidator for this field needs to "fire" when button2 is clicked but NOT when button1 is clicked.) Any suggestions for the simplest solution would be appreciated.
Thanks in advance
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可以使用验证组。
示例代码在这里:
You can use Validation Group.
Sample code here:
使用验证组。请参阅下一篇文章 http://www.dotnet-guide.com/validationgroups.html 。
Use validation groups. See the next article http://www.dotnet-guide.com/validationgroups.html.