ASP .NET RequiredFieldValidator in Validation Application Block of Enterprise Library 4.0

The Validation Application Block included in Enterprise Library 4.0 is a really cool block. I firstly tried to find the RequiredFieldValidator equivalent to ASP .NET. The fact is in the VAB there is only a StringLengthValidator which can be used for this task. There is a possibility to bend this validator to act exactly like the ASP .NET RequiredFieldValidator does.

 

Configure a ‘RequiredFieldValidator’ with Validation Application Block

1. Use the Configuration Utility to add a StringLengthValidator and rename it to ‘Required Validator’.

config

2. Configure the StringLengthValidator like in the following way.

properties

 

Remarks

You can add an addtional StringLengthValidator to validate for the max length of the string.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: