日期格式错误时不显示ErrorMessage="请输入正确的日期 ,怎么回事,是不是当isvaild为false时就应该显示错误信息
<asp:TextBox ID="txtStartDate" runat="server"CssClass="smallInput"></asp:TextBox>
< asp:CustomValidator ID="StartDate" EnableClientScript="false" runat="server"
OnServerValidate="CValidatorStartDate_ServerValidate" ValidationGroup="Contract"
ForeColor="Red" ErrorMessage="请输入正确的日期">
< /asp:CustomValidator>
protected void StartDate_ServerValidate(object source, ServerValidateEventArgs args)
{
args.IsValid = CommonHelper.DateTimeValidate(txtStartDate.Text.Trim());
}
protected void btnSearch_Click(object sender, EventArgs e)
{
Page.Validate ("Contract");
if (Page.IsValid ==false)
{
return;
}
setCollectionParametersFromControl();
}
控件放入后吧验证的那个日期规范写好后不用再写代码,它是在失去焦点后提示错误的。