Does form have validation errors?

6 posts, 0 answers
  1. Jeff
    Jeff avatar
    64 posts
    Member since:
    Dec 2011

    Posted 26 Mar 2012 Link to this post

    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?
  2. Maya
    Admin
    Maya avatar
    4062 posts

    Posted 29 Mar 2012 Link to this post

    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 >>
  3. UI for WPF is Visual Studio 2017 Ready
  4. Jeff
    Jeff avatar
    64 posts
    Member since:
    Dec 2011

    Posted 29 Mar 2012 Link to this post

    That looks like what I was looking for.  Thanks.
  5. Jeff
    Jeff avatar
    64 posts
    Member since:
    Dec 2011

    Posted 06 Apr 2012 Link to this post

    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.
  6. Peter
    Peter avatar
    37 posts
    Member since:
    Dec 2011

    Posted 20 Jan 2014 Link to this post

     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 
  7. Vera
    Admin
    Vera avatar
    263 posts

    Posted 21 Jan 2014 Link to this post

    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 >>
Back to Top
UI for WPF is Visual Studio 2017 Ready