我正在为实现 ASP.NET 验证(包括客户端)的网站制作申请表。
如果客户端验证失败,我需要在页面底部显示一条消息。类似于“请返回并检查您的答案”。
问题是,提交按钮的 OnClientClick 事件显然在客户端验证之前触发。
知道如何解决这个问题吗?
最佳答案
在您的 RequiredFieldValidator
上,如果您同时使用 ErrorMessage
和 Text
属性,则 ErrorMessage
的值将出现在ValidationSummary
,而 Text
的值将出现在 RequiredFieldValidator
的位置。
例如:
<RequiredFieldValidator
ErrorMessage="This will appear in the summary at the bottom of the page."
Text="This will appear in the middle of the page."
.../>
因此,要从摘要中隐藏 ErrorMessage
,只需将其设置为空字符串即可:
ErrorMessage=""
关于c# - 如果客户端验证失败显示消息?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3881040/