David Hayden [MVP C#]

Sponsors

The Lounge

News

  • CodeBetter.Com Home

Other Links

Teas

Patterns & Practices

Florida .NET Developer

Book Reviews

Tampa ASP.NET MVC Developer Group

Advertisement

Images in this post missing? We recently lost them in a site migration. We're working to restore these as you read this. Should you need an image in an emergency, please contact us at imagehelp@codebetter.com
Validation Application Block Presentation and New Features - Enterprise Library 3.0

Validation Application Block Presentation and New Features - Enterprise Library 3.0

by David Hayden

 

I presented the new Validation Application Block in Enterprise Library 3.0 last night to the Sarasota .NET Developers Group. An expected 1 hour presentation turned into 2 hours as we had a lot of really good discussion on the new block and Enterprise Library 3.0 as a whole. I expect a number of developers will be downloading the latest Enterprise LIbrary 3.0 CTP today based on our discussions last night.

The January CTP was just released on Friday and has a couple of new goodies in it for the Validation Application Block that I added to my list of demos for the presentation.

 

ASP.NET Integration

Tom mentioned this in an earlier post and you can find a quickstart in the downloads, but this feature is worth repeating :)

There is a new webcontrol that comes with the Validation Application Block called the PropertyProxyValidator. You can find it in the following assembly:

Microsoft.Practices.EnterpriseLibrary.Validation.Integration.AspNet.dll

The purpose of this control is to avoid duplicating your validation rules in 2 places- your web forms and your business classes. Instead of using ASP.NET Validation Controls to repeat the same validation rules on input controls that will be validated again with the same rules on the business class properties they represent, you can instead use the new PropertyProxyValidator control that reads the rules from the business class itself, saving you the step of creating redundant rules and the maintenance headache of managing rules in multiple places.

Here is an example using ValidatorAttributes, but you could also put your validation rules in an external configuration file.

 

Winforms Integration

You get similar functionality in the Winforms environment with the addition of a new Winform Control, called ValidationProvider, located in the following assembly:

 Microsoft.Practices.EnterpriseLibrary.Validation.Integration.WinForms.dll

Again, you just map each UI control to the appropriate business class property to get the validation rules to avoid creating rules in multiple places.

 

 

Visual Studio Integrated Configuration Editor Support

The group was also impressed with the new Configuration Editor for Enterprise Library built right into Visual Studio. The editor now supports the Validation Application Block in the new release:

 

 

 

One of the really valuable features of the editor with the Validation Application Block is that you can use it to discover and select types and properties in your application to save you a lot of manual typing:

 

 

 

Conclusion

Thanks to everyone who attended my presentation. I appreciated all the great discussion about Enterprise Library and the positive feedback on my presentation!

 

by David Hayden


Posted Wed, Jan 24 2007 10:49 AM by David Hayden

[Advertisement]

Comments

.Net Adventures wrote Interesting blog posts
on Wed, Jan 24 2007 5:05 PM

Jon Galloway - Google Personalized Homepage (IG) - Read a post inline David Hayden - Validation Application

Steven J. Ackerman wrote re: Validation Application Block Presentation and New Features - Enterprise Library 3.0
on Wed, Jan 24 2007 5:38 PM

That was a great presentation last night David - good slides, good demos and you obviously really knew the material and were excited about it. Kudos.

David Hayden wrote re: Validation Application Block Presentation and New Features - Enterprise Library 3.0
on Wed, Jan 24 2007 6:42 PM

Thanks, Steven. I had a lot of fun presenting the material. Thanks for all the great questions, too!

Christopher Steen wrote Link Listing - January 24, 2007
on Wed, Jan 24 2007 8:53 PM

Accessing and Updating Data in ASP.NET 2.0: Declaratively Caching Data [Via: ] Transforms, Opacity Masks...

Roger Williams wrote re: Validation Application Block Presentation and New Features - Enterprise Library 3.0
on Thu, Jan 25 2007 10:46 AM

I've had difficulty getting the Winforms ValidationProvider control to work properly.  When it attempts to validate a Textbox that was set to use the validator control, it thows an IllegalOperationException saying "The source type does not represent a valid type for validation provider."

I've filled the SourceTypeName property with the fully qualified (and correctly cased) class name that has the validation attributes in it.  

Any suggestions on where I'm going wrong would be greatly appreciated.

Thanks

Roger Williams

David Hayden wrote re: Validation Application Block Presentation and New Features - Enterprise Library 3.0
on Thu, Jan 25 2007 2:38 PM

Roger,

I was able to recreate the error by specifying an incorrect class name, so I think there is something wrong with the fully qualified class name in your ValidationProvider Settings.

Take a look at the quickstart that is included in the Enterprise Library 3.0 source code. Perhaps looking at the settings in the ValidationProvider will help.

In the example I created for my presentation, the SourceTypeName is

WinformIntegration.Customer, WinformIntegration

which represents the fully qualified class name.

Regards,

Dave

David Hayden [MVP C#] wrote South Florida Code Camp 2007 Presentations - Web Client Software Factory and Validation Application Block
on Fri, Jan 26 2007 11:19 AM

I will be speaking at the South Florida Code Camp on Saturday, February 10th, 2007. You can register