日期格式错误时不显示ErrorMessage="请输入正确的日期 ,怎么回事
<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();
}
<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();
}
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货