从不工作的代码设置MaskedEditValidator MaxValue

时间:2015-09-25 06:35:52

标签: c# asp.net ajaxcontroltoolkit

我正在尝试设置MaskedEditValidator的MaxValue,它是日期类型,但在单击“提交”按钮后不在MaxValue上进行验证。下面是我的蒙面编辑验证器的HTML代码



<asp:TextBox ID="txtLectureDate" runat="server" class="form-control" placeholder="Please Select End Date" TabIndex="3" OnTextChanged="txtEndDate_TextChanged" ValidationGroup="Submit" AutoPostBack="true">
</asp:TextBox>
<ajaxtoolkit:CalendarExtender ID="cldrexEndDate" runat="server" TargetControlID="txtLectureDate" Format="dd/MM/yyyy" PopupButtonID="imgECal"
CssClass=" cal_Theme1">
</ajaxtoolkit:CalendarExtender>

<ajaxtoolkit:MaskedEditExtender ID="meeEndDate" runat="server" TargetControlID="txtLectureDate" Mask="99/99/9999" MaskType="Date" AcceptNegative="Left" MessageValidatorTip="false" InputDirection="LeftToRight">
</ajaxtoolkit:MaskedEditExtender>

<ajaxtoolkit:MaskedEditValidator ID="mevEndDate" runat="server" ControlToValidate="txtLectureDate" ControlExtender="meeEndDate" IsValidEmpty="false" EmptyValueMessage="Please Enter End Date" ErrorMessage="Please Enter Valid Date in [dd/MM/yyyy]" InvalidValueMessage="Please Enter Valid Date" MaximumValueMessage ="Attendance Date Should Not Be Greater Than Current Date" ValidationGroup="Submit" Display="None">
</ajaxtoolkit:MaskedEditValidator>
&#13;
&#13;
&#13;

以下是我的代码背后

protected void Page_Load(object sender, EventArgs e)
{
    if (!Page.IsPostBack)
    {
        mevEndDate.MaximumValue = DateTime.UtcNow.AddHours(5.5).ToString("dd/MM/yyyy");
    }
}

请帮助我。

1 个答案:

答案 0 :(得分:1)

请确保MaskedEdit.UserDateFormat =“DayMonthYear”。我还注意到,验证仅在文本框模糊时发生。