我正在使用带有 onservervalidation 的 CustomValidator。服务器端函数正常触发并返回 false 值,但验证器未显示错误消息,而是进入下一步。
代码:
<asp:CustomValidator OnServerValidate="Naminee_Validate"
ErrorMessage="You cannot set yourself as Nominee"
runat="server" Display="None">*</asp:CustomValidator>
<asp:ValidationSummary ID="ValidationSummary3" runat="server" DisplayMode="SingleParagraph"
HeaderText="Error in saving the data: " />
protected void Naminee_Validate(object sender, ServerValidateEventArgs e)
{
if (....)
{
e.IsValid = false;
}
else
{
e.IsValid = true;
}
}
}