Hi all,
I have this fiddly situation where I have a MaskedEditExtender to give me a date mask on a TextBox, and a MaskedEditValidator to give the user feedback if the date is invalid - empty is allowed. I also have a CalendarExtender on this TextBox so the user doesn't have to type. I have two things to note:
- When you set "ClearMaskOnLostFocus" of the extended TextBox properties, the CalendarExtender doesn't work - you can set the date, but when you click away to hide the calendar, it also resets the mask and the TextBox content.When you do not have "ClearMaskOnFocus" set, allow empty values, click in the TextBox (to bring up the input mask), and click out again - the input mask remains and any validation message you attached to the MaskedEditValidator now appears - this goes against what I expect to be correct, as the TextBox is empty.
The third problem that I won't number is that the two problems are exacerbated by the CalendarExtender, without that only the second problem would persist, which could furthermore be solved by setting "ClearMaskOnLostFocus". I haven't tested what happens to the TextBox and its values etc in any other situation.
Has anyone else encountered this issue?
Temporarily, does anyone have a work around? I require the calendar object to give the user a mouse option, and need a basic input mask toat leastblock out alphabetic characters and format the date in dd/MM/yyyy format.
Thanks in advance!
Hello. Might be a bit late for an reply, but I had the same problem as you. I was using a textBox with a MaskedEdit & a CalendarExtender.
I was clicking on the textbox, the calendar was showing up. One time on two, it was telling me the date was invalid (but it was valid). And the weirdest thing was when I clicked on a date, it was writing it in the textbox, saying it was valid. But as soon as I clicked outside the calendar to close it, the validator was emptying the textbox and telling me it was an invalid date.
I was losing it, but strangely, when I read your post I decided to try adding a "ClearMaskOnLostFocus="False" (that parameter wasn't originally declared so I don't know what is the default value). and now ... it WORKS 100%.
Btw, I'm using DD/MM/YYYY format. The easiest trick to do that is simply to set the MaskedEditExtender's culture to "en-GB" and it worked #1. Here's my code of a working textbox with a calendar, all using the DD/MM/YYYY format.
<asp:LabelID="Label5"runat="server"Font-Bold="True"Font-Size="Smaller"Style="text-align: right"
Text="DATE DéPART:"Width="143px"></asp:Label>
<asp:TextBoxValidationGroup="dateValidator1"MaxLength="1"ID="dateDepart"runat="server"style="text-align:center"Width="77px"></asp:TextBox>
<asp:LabelID="Label14"runat="server"Width="68px"></asp:Label>
<cc1:MaskedEditValidatorID="MaskedEditValidator1"runat="server"
ControlExtender="MaskedEditExtender1"SetFocusOnError="true"
Display="Dynamic"
ControlToValidate="dateDepart"IsValidEmpty="False"
EmptyValueMessage="Date is required"
InvalidValueMessage="Date is invalid"
ValidationGroup="dateValidator1"
TooltipMessage="Input a Date"/>
<asp:LabelID="Label7"runat="server"Width="75px"></asp:Label><br/>
<cc1:CalendarExtenderID="CalendarExtender1"runat="server"Format="dd/MM/yyyy"TargetControlID="dateDepart">
</cc1:CalendarExtender>
<br/>
<br/>
<cc1:MaskedEditExtenderID="MaskedEditExtender1"runat="server"
MaskType="Date"TargetControlID="dateDepart"
Mask="99/99/9999"CultureName="en-GB"
MessageValidatorTip="true"OnFocusCssClass="MaskedEditFocus"
OnInvalidCssClass="MaskedEditError"
ClearMaskOnLostFocus="false"DisplayMoney="Left"
AcceptNegative="Left"/>
<br/>
Pat.
I ran into some of the same problems. My issue was allowing for empty values w/out invalidating. Seethis post for more info and sample code.
Hope this helps.
No comments:
Post a Comment