我有一个带有一些自定义验证的表单。表单上有一个按钮,可以将用户带到“确认页面”以显示订单的所有详细信息。
页面验证
<asp:TextBox ID="txtBillingLastName" Name="txtBillingLastName"
runat="server" CssClass="txtbxln required"></asp:TextBox>
<asp:CustomValidator
ID="CustomValidatorBillLN" runat="server"
ControlToValidate="txtBillingLastName"
OnServerValidate="CustomValidatorBillLN_ServerValidate"
ValidateEmptyText="True">
</asp:CustomValidator>
验证器代码
protected void CustomValidatorBillLN_ServerValidate(object sender, ServerValidateEventArgs args)
{
args.IsValid = isValid(txtBillingLastName);
}
但是,如果我将 PostBackUrl 或 Response.Redirect 添加到按钮 onclick 方法,则所有验证控件都将被忽略。
我可以使用 onclick 方法调用所有验证方法,但这似乎不是一个优雅的解决方案。
我试过设置 CausesValidation=False 没有运气。
有什么建议么?