I am using the ServerSideValidationExtender with a custom PropertyProxyValidator in conjuction with a RadMaskedTextBox. When the PropertyProxyValidator fires the OnChanged event the value passed into the event is not the new value of the text box but rather the last value. So in the below example the page renders with the text 1111-11-11 in the box. I change the value to 1111-11-22. Tab out of the box. The PropertyProxyValidator does get fired but the value passed into the method is 11111111 not 11111122.
I know we can possibly use other controls for date entry but we have a requirement for displaying the edit mask and I am trying to evaluate how we can use our design for the validation with this RadMaskedTextBox. As well even if this was not a date the issue would be the same.
Our OnValueConvert method has the following code in it for our HCPropertyProxyValidator implementation:
I know we can possibly use other controls for date entry but we have a requirement for displaying the edit mask and I am trying to evaluate how we can use our design for the validation with this RadMaskedTextBox. As well even if this was not a date the issue would be the same.
<telerik:RadMaskedTextBox ID="ServiceDateTextBox" runat="server" Mask="####-##-##" PromptChar="_" Text='11111111' /> |
<HCFW:HCPropertyProxyValidator ID="HCPropertyProxyValidator1" runat="server" |
ControlToValidate="ServiceDateTextBox" PropertyName="ServiceDate" SourceTypeName="HC.Modules.Provider.PresentationEntities.Member, HC.Modules.Provider" /> |
<WCSFX:ServerSideValidationExtender ID="ServerSideValidationExtender1" runat="server" TargetControlID="HCPropertyProxyValidator1" /> |
Our OnValueConvert method has the following code in it for our HCPropertyProxyValidator implementation:
private void OnValueConvert(object sender, ValueConvertEventArgs e) |
{ |
if (e.TargetType.Equals(typeof(System.DateTime))) |
{ |
string value = e.ValueToConvert as string; |
DateTime convertedValue; |
bool success = DateTime.TryParse(value, |
System.Threading.Thread.CurrentThread.CurrentUICulture, |
System.Globalization.DateTimeStyles.None, |
out convertedValue); |
if (success) |
{ |
e.ConvertedValue = convertedValue; |
} |
else |
{ |
e.ConversionErrorMessage = "Date is not a valid value."; |
e.ConvertedValue = null; |
} |
} |
} |