自定义验证器仅在第一次单击按钮时触发?
我的页面上有一个自定义验证器和一些其他验证器。但是,每当我第一次单击“提交”按钮时,它只会触发自定义验证器,而当我第二次单击该按钮时,它会验证其余的验证器。如果您有任何解决方案,请告诉我。
谢谢
I have a custom validator and some other validators on the page. But whenever I click the submit button for first time it only fires the custom validator and when I click the button for second time it's validating rest of the validators. Please let me know if you have any solution.
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
检查您的
Page_Load
以确保您在第二次调用后没有隐藏或启用某些内容。我之前也遇到过类似的问题,这让我很困惑,直到我意识到我正在操作包含验证器的Page_Load
中的Panel
。除此之外,您还需要发布代码(您的
Page_Load
和Click
事件)。Check your
Page_Load
to make sure you are not hiding or enabling something after the second call. I had a similar problem before and it confused the heck out of me until I realized I was manipulating aPanel
in thePage_Load
that contained the validator.Other than that, you would need to post code (your
Page_Load
andClick
event).在客户端,当
被调用时,asp.net 验证器(例如必需的字段验证器)被禁用,并且它不会在验证器集合中列出,并且不会验证此验证器验证的字段,并且如果自定义验证通过,则页面回发。
为了避免这种情况,请在自定义验证代码或其他位置显式启用 asp.net 验证器,以便在页面回发之前或在自定义验证开始时激活它,如下所示:
rfvDDLStatus ==>未触发的必填字段验证器
..ValidatorEnable ==>用于启用 asp.net 验证器的客户端 API
On Client Side when
Is called, asp.net validators e.g required field validators are disabled and it does not gets listed in validators collection and does not validate the field validated by this validator and page post backs if custom validation passes.
To avoid this explicitly enable asp.net validators in Custom validation code or else where so that it gets activated before page postback or in the begiining of custom validation as follows:
rfvDDLStatus ==> required field validator
which was not firing..ValidatorEnable ==> Client API
to enable asp.net validator