This is a migrated thread and some comments may be shown as answers.

Does form have validation errors?

5 Answers 94 Views
DataForm
This is a migrated thread and some comments may be shown as answers.
Jeff
Top achievements
Rank 1
Jeff asked on 26 Mar 2012, 09:46 PM
I have a user control that contains a RadDataForm and a button.

The button is bound to a custom command that has xxx_CanExecute() and xxx_Executed() methods defined.

I want xxx_CanExecute() to set e.CanExecute to false, if the form has any validation errors.  I'm getting the user control passed as sender, and from that I can get a reference to the RadDataForm.  But I can't for the life of me figure out how to tell if the form has any validation errors.  In the debugger I can see a validationErrors collection on the form, but that seems to be private. ValidateItem() always returns true, regardless.

Seems to me that I'm missing something simple.  Can someone point me in the right direction?

5 Answers, 1 is accepted

Sort by
0
Maya
Telerik team
answered on 29 Mar 2012, 02:17 PM
Hi Jaffrey,

You can try getting access to the ValidationSummary of RadDataForm and work with its HasErrors property.
For example: 

var hasErrors = this.DataForm1.ValidationSummary.HasErrors;
 
Will that approach be suitable for your scenario ? 

Kind regards,
Maya
the Telerik team
Sharpen your .NET Ninja skills! Attend Q1 webinar week and get a chance to win a license! Book your seat now >>
0
Jeff
Top achievements
Rank 1
answered on 29 Mar 2012, 03:36 PM
That looks like what I was looking for.  Thanks.
0
Jeff
Top achievements
Rank 1
answered on 06 Apr 2012, 04:01 PM
I'm not sure whether it's a bug, or but ValidationSummary.HasErrors always seems to be false.

I made a simple test page, and I'm seeing ValidationSummary.Errors.Count() increment, when I type invalid content into a textbox, and I'm seeing the validation error display at the bottom of the form, but HasErrors is still false.

Still, "Errors.Count() > 0" will work for my purposes.
0
Peter
Top achievements
Rank 1
answered on 20 Jan 2014, 11:01 AM
 I think Jeff is right: "ValidationSummary.HasErrors always seems to be false"

In my application  ValidationSummary.HasErrors also is false although the Validationsummary window shows clearly an error printed red.

If this is not a bug, please post a demo how to use  ValidationSummary.HasErrors correctly 
0
Vera
Telerik team
answered on 21 Jan 2014, 08:21 AM
Hello,

I have logged the problem for a further investigation. As suggested, you can use the count ValidationSummary.Errors instead.

Please excuse us for the inconvenience caused.

Regards,
Vera
Telerik
TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for WPF.
Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
Sign up for Free application insights >>
Tags
DataForm
Asked by
Jeff
Top achievements
Rank 1
Answers by
Maya
Telerik team
Jeff
Top achievements
Rank 1
Peter
Top achievements
Rank 1
Vera
Telerik team
Share this question
or