我有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"/>
请伙计们,帮助我。
答案 0 :(得分:0)
试试这个:
Please Enter Time:
<asp:TextBox ID="txtBoxTime" runat="server"></asp:TextBox>
<ajax:MaskedEditExtender ID="MaskedEditExtender3" runat="server" TargetControlID="txtBoxTime"
Mask="99:99:99" MaskType="Time" MessageValidatorTip="true" InputDirection="RightToLeft" >
</ajax:MaskedEditExtender>
<ajax:MaskedEditValidator ID="MaskedEditValidator3" runat="server" ControlExtender="MaskedEditExtender3"
ControlToValidate="txtBoxTime" IsValidEmpty="false" MaximumValue="23:59:59" MinimumValue="00:00:00"
EmptyValueMessage="Please enter time"
MaximumValueMessage="Please enter time less than 23:59:59" MinimumValueMessage="Please enter time greater than 00:00:00" >
</ajax:MaskedEditValidator>
参考:http://www.devasp.net/net/articles/display/1373.html
别忘了放置验证组