CodeBetter.Com
CodeBetter.Com
RSS 2.0 via Feedburner
           Do you Twitter? Follow us @CodeBetter

David Hayden [MVP C#]

         .NET Tutorials, Patterns, and Practices

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



Comments

.Net Adventures said:

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

# January 24, 2007 5:05 PM

Steven J. Ackerman said:

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.

# January 24, 2007 5:38 PM

David Hayden said:

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

# January 24, 2007 6:42 PM

Christopher Steen said:

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

# January 24, 2007 8:53 PM

Roger Williams said:

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

# January 25, 2007 10:46 AM

David Hayden said:

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

# January 25, 2007 2:38 PM

David Hayden [MVP C#] said:

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

# January 26, 2007 11:19 AM
Check out Devlicio.us!

Our Sponsors

Free Tech Publications

This Blog

Syndication

News

CodeBetter.Com Home