This question is locked. New answers and comments are not allowed.
Hi Telerik,
Are there some known issues about validation with the RadDataForm when not using automatic field generation?
I just converted a Silverlight Toolkit Dataform to a RadDataForm to do a little comparison between them and now some (most) validation checks seems to be skipped. Maybe I am doing something wrong but I can't find my errors and everything was working as expected when using the Silverlight Toolkit Dataform.
My dataform is for creating users, and it is bound to an ObservableCollection of entities called RegistrationData. RegistrationData has some [RegularExpression] and [required] validation attributes, and in some cases the regular expression doesnt seem to be taken into account. I also dont see anything in the validation summary (althought I did not turn it off) and the form accepts my click on "ok" even if the fields don't respect their [RegularExpression] and [required] attributes.
Just to give an example, what I see is that the regEx for the name is being validated when the field lose focus, but this is not true for the email, and no validation is called when clicking on the OK button.
Here is the code for my entity:
Some constants for my regular expressions:
And here is the shortened version of my view's dataform (I removed the readonly and edit templates):
To avoid adding to an already long post, Im not including my view's code-behind or my viewModel's code since it is quite lenghty and irrelevant (I think) to this problem.
Thank you for any help.
EDIT: I Forgot to mention that Im using the latest version (2011.1.419.1040)
Are there some known issues about validation with the RadDataForm when not using automatic field generation?
I just converted a Silverlight Toolkit Dataform to a RadDataForm to do a little comparison between them and now some (most) validation checks seems to be skipped. Maybe I am doing something wrong but I can't find my errors and everything was working as expected when using the Silverlight Toolkit Dataform.
My dataform is for creating users, and it is bound to an ObservableCollection of entities called RegistrationData. RegistrationData has some [RegularExpression] and [required] validation attributes, and in some cases the regular expression doesnt seem to be taken into account. I also dont see anything in the validation summary (althought I did not turn it off) and the form accepts my click on "ok" even if the fields don't respect their [RegularExpression] and [required] attributes.
Just to give an example, what I see is that the regEx for the name is being validated when the field lose focus, but this is not true for the email, and no validation is called when clicking on the OK button.
Here is the code for my entity:
public sealed partial class RegistrationData{ [Key] [Required(ErrorMessageResourceName = "ValidationErrorRequiredField", ErrorMessageResourceType = typeof(ValidationStrings))] [Display(Name = "UserNameLabel", ResourceType = typeof(RegistrationDataStrings))] [RegularExpression(Constants.regexName, ErrorMessageResourceName = "ValidationErrorInvalidUserName", ErrorMessageResourceType = typeof(RegistrationDataStrings))] [StringLength(255, MinimumLength = 4, ErrorMessageResourceName = "ValidationErrorBadUserNameLength", ErrorMessageResourceType = typeof(RegistrationDataStrings))] public string UserName { get; set; } [Key] [Required(ErrorMessageResourceName = "ValidationErrorRequiredField", ErrorMessageResourceType = typeof(ValidationStrings))] [Display(Name = "EmailLabel", ResourceType = typeof(RegistrationDataStrings))] [RegularExpression(Constants.regexEmail, ErrorMessageResourceName = "ValidationErrorInvalidEmail", ErrorMessageResourceType = typeof(RegistrationDataStrings))] public string Email { get; set; } [Required(ErrorMessageResourceName = "ValidationErrorRequiredField", ErrorMessageResourceType = typeof(ValidationStrings))] [Display(Name = "SecurityQuestionLabel", ResourceType = typeof(RegistrationDataStrings))] public string Question { get; set; } [Required(ErrorMessageResourceName = "ValidationErrorRequiredField", ErrorMessageResourceType = typeof(ValidationStrings))] [Display(Name = "SecurityAnswerLabel", ResourceType = typeof(RegistrationDataStrings))] public string Answer { get; set; } public int? AvocatID { get; set; } [Key] public int UserID { get; set; } public string TempPassword { get; set; }}Some constants for my regular expressions:
public partial class Constants{ public const string searchContentSeparator = "#"; public const string adminRoleName = "Admin"; public const string regexName = @"^[a-zA-Z0-9_]*$"; public const string regexEmail = @"^([\w-\.]+)@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([\w-]+\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$"; public const string regexPostalCode = @"^\s*[a-zA-Z]\d[a-zA-Z](\s)?\d[a-zA-Z]\d\s*$"; public const string regexPhoneNumber = @"^[01]?[- .]?\(?[2-9]\d{2}\)?[- .]?\d{3}[- .]?\d{4}$";}And here is the shortened version of my view's dataform (I removed the readonly and edit templates):
<telerik:RadDataForm x:Name="dataFormUser" ItemsSource="{Binding Users, Mode=TwoWay}" CurrentItem="{Binding SelectedUser, Mode=TwoWay}" AutoGenerateFields="False" AutoEdit="False" AutoCommit="False" Margin="2" DeletingItem="dataFormUser_DeletingItem"> <i:Interaction.Triggers> <i:EventTrigger EventName="EditEnded"> <mvvmlightcmd:EventToCommand Command="{Binding EditEndedCommand}" /> </i:EventTrigger> </i:Interaction.Triggers> <telerik:RadDataForm.NewItemTemplate> <DataTemplate> <Grid> <Grid.RowDefinitions> <RowDefinition Height="Auto" /> <RowDefinition Height="Auto" /> <RowDefinition Height="Auto" /> <RowDefinition Height="Auto" /> <RowDefinition Height="Auto" /> <RowDefinition Height="Auto" /> <RowDefinition Height="Auto" /> </Grid.RowDefinitions> <telerik:DataFormDataField Grid.Row="0" DataMemberBinding="{Binding UserName, Mode=TwoWay}" Label="{Binding Path=RegistrationDataStrings.UserNameLabel, Source={StaticResource ResourceWrapper}}"/> <telerik:DataFormDataField Grid.Row="1" x:Name="fieldEmploye" Loaded="fieldEmploye_Loaded" Label="{Binding Path=RegistrationDataStrings.Employee, Source={StaticResource ResourceWrapper}}" > <telerik:RadComboBox IsEditable="False" ItemTemplate="{StaticResource AvocatItemTemplate}" SelectedValuePath="AvocatID" SelectedValue="{Binding SelectedUserAvocat, Mode=TwoWay}" Name="radComboBoxEmploye" Loaded="radComboBoxEmploye_Loaded"/> </telerik:DataFormDataField> <telerik:DataFormDataField Grid.Row="2" Label="{Binding Path=RegistrationDataStrings.PasswordLabel, Source={StaticResource ResourceWrapper}}"> <PasswordBox Password="{Binding Password, Mode=TwoWay}" Name="PasswordBox" Loaded="PasswordBox_Loaded" /> </telerik:DataFormDataField> <telerik:DataFormDataField Grid.Row="3" Label="{Binding Path=RegistrationDataStrings.PasswordConfirmationLabel, Source={StaticResource ResourceWrapper}}"> <PasswordBox Password="{Binding PasswordConfirmation, Mode=TwoWay}" Name="PasswordConfirmationBox" Loaded="PasswordConfirmationBox_Loaded" /> </telerik:DataFormDataField> <telerik:DataFormDataField Grid.Row="4" DataMemberBinding="{Binding Email, NotifyOnValidationError=True, ValidatesOnDataErrors=True, ValidatesOnExceptions=True}" Label="{Binding Path=RegistrationDataStrings.EmailLabel, Source={StaticResource ResourceWrapper}}"/> <telerik:DataFormDataField Grid.Row="5" Grid.ColumnSpan="2" Label="{Binding Path=RegistrationDataStrings.SecurityQuestionLabel, Source={StaticResource ResourceWrapper}}"> <telerik:RadComboBox IsEditable="False" SelectedValue="{Binding Question, Mode=TwoWay}" Name="radComboBoxQuestion" Loaded="radComboBoxQuestion_Loaded" /> </telerik:DataFormDataField> <telerik:DataFormDataField Grid.Row="6" Grid.ColumnSpan="2" DataMemberBinding="{Binding Answer, Mode=TwoWay, NotifyOnValidationError=True, ValidatesOnDataErrors=True, ValidatesOnExceptions=True}" Label="{Binding Path=RegistrationDataStrings.SecurityAnswerLabel, Source={StaticResource ResourceWrapper}}"/> </Grid> </DataTemplate> </telerik:RadDataForm.NewItemTemplate></telerik:RadDataForm>To avoid adding to an already long post, Im not including my view's code-behind or my viewModel's code since it is quite lenghty and irrelevant (I think) to this problem.
Thank you for any help.
EDIT: I Forgot to mention that Im using the latest version (2011.1.419.1040)