C# asp自定义验证程序启动太晚

C# asp自定义验证程序启动太晚,c#,asp.net,customvalidator,C#,Asp.net,Customvalidator,我有一个带有日期自定义验证程序的表单: <asp:CustomValidator runat="server" ID="cusCustom" ControlToValidate="fdate" Display="None" OnServerValidate="customdate" ErrorMessage="You need to book 24 hours earlier" /> <ajaxToolkit:ValidatorCalloutExtender ID="

我有一个带有日期自定义验证程序的表单:

<asp:CustomValidator runat="server" ID="cusCustom"
 ControlToValidate="fdate"
 Display="None"
 OnServerValidate="customdate"
 ErrorMessage="You need to book 24 hours earlier" />
<ajaxToolkit:ValidatorCalloutExtender 
ID="ValidatorCalloutExtender4"
TargetControlId="cusCustom" runat="server">
</ajaxToolkit:ValidatorCalloutExtender>
问题是它工作正常,它检测到它需要检测的东西并触发警告,但是。。。太晚了!如果我在表单中输入了错误的日期,我可以提交它,并且我将在下次打开带有表单的modalpopup以输入新预订时发现关于此错误验证的警告

我拥有的所有其他相同形式的验证器都可以正常工作。这是启动表单的按钮:

  <asp:Button ID="btnNew" runat="server" Text="New" CausesValidation="false" /> 

它将
CausesValidation
设置为false,这对于普通的验证器非常有效。只是自定义的一个运行得太晚了


有什么建议吗?

您可能应该让弹出窗口触发一个事件,以便在关闭后检查输入是否有效。我将为您提供一些伪代码

<popupModalBox OnClose="PopupModal_OnClose" />
<popupModalBox OnClose="PopupModal_OnClose" />
void PopupModal_OnClose(object sender, EventArgs e)
{
    if (Page.IsValid)
    {
        // Do something
    }
    else
    {
        // Do something else
    }
}