I have 2 textbox which accept time from users, to which I have set the Maskededitextender and maskededitvalidator as follows:
textbox 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>
textbox 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>
then I have a button on whose click a process happens, but if the maskededitvalidator displays invalid data, the button's code behind must not execute. But in my case the code behind executes despite the maskededitvalidator displaying invalid data. I have set the validation group of all the concerned controls, yet the issue.
Button:
<asp:Button ID="btnLoadEmployees" ValidationGroup="date" CssClass="button" runat="server" Text="Load Employees" OnClick="btnLoadEmployees_Click"/>
Please guys, help me in this.
Try this:
Ref from : http://www.devasp.net/net/articles/display/1373.html
dont forget to put validation Groups