我有 2 个接受用户时间的文本框,我将 Maskededitextender 和 maskededitvalidator 设置为如下:
文本框 1:
<asp:TextBox ID="txtInTime" Text ="00:00" CssClass="txtbox" MaxLength="5"
Width="43px" runat="server" ValidationGroup="date"
></asp:TextBox>
<cc1:MaskedEditExtender ID="MaskedEditExtender2" runat="server" TargetControlID="txtInTime"
Mask="99:99" MessageValidatorTip="true" MaskType="Time" InputDirection="RightToLeft"
ErrorTooltipEnabled="True" />
<cc1:MaskedEditValidator ID="MaskedEditValidator2" runat="server" ControlExtender="MaskedEditExtender2"
ControlToValidate="txtInTime" MaximumValue="23:59" MinimumValue="00:00"
MaximumValueMessage="23:59" ValidationGroup="date"
InvalidValueBlurredMessage="Time Invalid"
MinimumValueMessage="Time must be greater than 00:00:00" ForeColor ="Red"
ToolTip="Enter time between 00:00 to 23:59">
</cc1:MaskedEditValidator>
文本框 2:
<asp:TextBox ID="txtOutTime" Text ="00:00" CssClass="txtbox" MaxLength="5"
Width="43px" runat="server" ValidationGroup="date"
></asp:TextBox>
<cc1:MaskedEditExtender ID="MaskedEditExtender3" runat="server" TargetControlID="txtOutTime"
Mask="99:99" MessageValidatorTip="true" MaskType="Time" InputDirection="RightToLeft"
ErrorTooltipEnabled="True" />
<cc1:MaskedEditValidator ID="MaskedEditValidator1" runat="server" ControlExtender="MaskedEditExtender3"
ControlToValidate="txtOutTime" MaximumValue="23:59" MinimumValue="00:00"
MaximumValueMessage="23:59" ValidationGroup="date"
InvalidValueBlurredMessage="Time Invalid"
MinimumValueMessage="Time must be grater than 00:00:00" ForeColor ="Red"
ToolTip="Enter time between 00:00 to 23:59">
</cc1:MaskedEditValidator>
然后我有一个按钮,其点击过程发生,但如果 maskededitvalidator 显示无效数据,则按钮后面的代码不得执行。但在我的情况下,尽管 maskededitvalidator 显示无效数据,但后面的代码仍会执行。我已经设置了所有相关控件的验证组,但是问题。
按钮:
<asp:Button ID="btnLoadEmployees" ValidationGroup="date" CssClass="button" runat="server" Text="Load Employees" OnClick="btnLoadEmployees_Click"/>
请大家帮帮我。