验证问题总结
我的 asp.net 页面上有一个小联系页面。 我有大约 5 个可能会出错的验证器,并且我有一个 ValidationSummary。
问题是,当我点击“SubmitButton”时,所有控件的 div 应该消失,并且带有 ValidationSummary 的 div 应该出现。
但我不知道如何实现这一点,因为在普通按钮/链接按钮上我不会有 DIV 的回发可见/不可见。通过回发,我将不会获得 ValidationSummary 的信息。
希望我能正确解释,以便您理解我:)
I have a little contact-page on my asp.net page.
I have ~5 validators that can go wrong there and I have a ValidationSummary.
The problem ist, when I hit the "SubmitButton" the div wit all controls should disappear and the div with the ValidationSummary should appear.
But I have no idea how to realiza that, because on a normal button / linkbutton I will not have a postback visible / invisible the DIV's. With a postback, I will not have the information for the ValidationSummary.
Hope I could explain it correctly, so you understand me :)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
验证摘要显示/隐藏本身,这是您想要控制的吗?无论如何,你是对的,你必须在客户端 JavaScript 中执行此操作。
一种方法是手动调用验证方法 Page_ClientValidate,并且不依赖默认的验证功能。
另一种方法是通过执行以下操作来替换默认客户端功能:
查看客户端上可用的验证方法,您可以使用此技术来覆盖默认实现:http://msdn.microsoft.com/en-us/library/aa338815(v=vs.71).aspx
HTH。
The validation summary shows/hides itself, is that something you want to control? At any rate, you are right, you have to do this in client-side JavaScript.
One way is to manually call the validation method Page_ClientValidate, and don't rely on the default validation functionality.
Another way is to replace the default client functionality by doing:
Take a look at the validation methods available to you on the client, that you can use this technique to override the default implementations: http://msdn.microsoft.com/en-us/library/aa338815(v=vs.71).aspx
HTH.