如何确定哪个自定义验证器将首先触发
我有两个位于同一验证组中的自定义验证器。该验证组通过一键启动。我的问题是,自定义验证器将按什么顺序触发?看起来放在 aspx 页面前面的验证器首先触发,但我不想仅仅依赖于此。有什么想法吗?
I have two custom validators that are in the same validation group. This validation group is launched by one button. My question is, in what order will the custom validators fire in? It appears that the validator that is placed earlier in the aspx page fires first, but I don't want to rely solely on this. Any thoughts?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
它们将按照它们在控件树中存在的顺序触发,因为页面生命周期事件从顶部向下递归到该树。验证事件又由生命周期事件触发。
They will fire in the order they exist in the control tree, since the page lifecycle events recurse down that tree from the top. The validation event is, in turn, fired from a lifecycle event.
我不会依赖这个。我会假设任何顺序,因为这取决于实现。例如,如果您的服务器有多个处理器或者您在 Mono 上运行它,则稍后可能会发生变化。
I would not rely on this. I would assume any order as this is implementation dependent. It may later change if your server has multiple processors or if you run it on Mono, for example.