Enterprise Library - Hands-on-Labs - Validation - Lab 9

Topics: Validation Application Block
Jan 25, 2010 at 3:59 PM

Enterprise Library 4.1 Hands-on-Lab 7 Task 4 is concerned with using a ValidationProvider added to the VS2008 Designer and configuring it with an ErrorProvider.  The ValidationProvider is then applied to both the Customer and Address fields in MainForm.  When the test application is run, if you leave all the fields blank and click the Accept button, an errorprovider icon is shown on the First Name field with an appropriate message when you mouse over it.  However, there appear to be some problem areas.  Here are my questions.

1. Why are there no errorprovider icons on the other invalid fields?

2. If I correct the First Name by entering a valid first name, and click Accept, instead of getting an errorprovider icon on the next invalid field, I get the MessageBox popup showing all the invalid fields (without First Name, which is now valid).

3. If I quit the application, restart it, enter a valid name for First Name, and click Accept, I expect to get an errorprovider icon on at least the new first invalid field, Last Name, but instead I get the MessageBox popup.

The implementation of ValidationProvider with ErrorProvider does not seem to operate as one would expect.  What is needed to show the ErrorProvider icons on all invalid fields?

Thanks,

nick.piazza@carefusion.com

Jan 26, 2010 at 2:43 AM

You are getting the MessageBox popup because of the code for the acceptButton's Click event. 

There are no errorprovider icons on the other invalid fields as the method that was used to perform validation was to create the Customer and Address object based on the values entered on the win form controls and calling Validation.Validate on those objects.  This logic is also on the acceptButton's Click event.  To show the ErrorProvider icons on all invalid fields, you need to call validationProvider.PerformValidation on each control or simply call this.ValidateChildren(). 

 

Sarah Urmeneta
Global Technology and Solutions
Avanade, Inc.
entlib.support@avanade.com

Jan 26, 2010 at 12:58 PM

Thanks for the information and quick reply.

Nick Piazza

From: AvanadeSupport [mailto:notifications@codeplex.com]
Sent: Monday, 25 January, 2010 19:43
To: Piazza, Nick
Subject: Re: Enterprise Library - Hands-on-Labs - Validation - Lab 9 [entlib:81953]

From: AvanadeSupport

You are getting the MessageBox popup because of the code for the acceptButton's Click event.

There are no errorprovider icons on the other invalid fields as the method that was used to perform validation was to create the Customer and Address object based on the values entered on the win form controls and calling Validation.Validate on those objects. This logic is also on the acceptButton's Click event. To show the ErrorProvider icons on all invalid fields, you need to call validationProvider.PerformValidation on each control or simply call this.ValidateChildren().

Sarah Urmeneta
Global Technology and Solutions
Avanade, Inc.
entlib.support@avanade.com

Read the full discussion online.

To add a post to this discussion, reply to this email (entlib@discussions.codeplex.com)

To start a new discussion for this project, email entlib@discussions.codeplex.com

You are receiving this email because you subscribed to this discussion on CodePlex. You can unsubscribe on CodePlex.com.

Please note: Images and attachments will be removed from emails. Any posts to this discussion will also be available online at CodePlex.com

  
  
_________________________________________________

This message is for the designated recipient only and may contain privileged, proprietary
or otherwise private information. If you have received it in error, please notify the sender
immediately and delete the original. Any other use of the email by you is prohibited.

Dansk - Deutsch - Espanol - Francais - Italiano - Japanese - Nederlands - Norsk - Portuguese
Svenska: www.cardinalhealth.com/legal/email