The updated ASP.NET page now looks like it does below. I
only included the two new properties. Note that it looks the same as the other
properties from the previous example.
Listing 10
<tr>
<td>Zip Code</td>
<td>
<asp:TextBox ID="txtZipCode" runat="server" />
<el:PropertyProxyValidator ID="ppvZipCode"
runat="server"
SourceTypeName="Mains.Examples.User,App_Code"
PropertyName="ZipCode" RulesetName="primary"
ControlToValidate="txtZipCode">
*</el:PropertyProxyValidator>
</td>
</tr>
<tr>
<td>Authorization Code</td>
<td>
<asp:TextBox ID="txtAuthorizationCode" runat="server" />
<el:PropertyProxyValidator ID="ppvAuthorizationCode"
runat="server"
SourceTypeName="Mains.Examples.User,App_Code"
PropertyName="AuthorizationCode" RulesetName="primary"
ControlToValidate="txtAuthorizationCode">
*</el:PropertyProxyValidator>
</td>
</tr>
When performing the validation on an empty form, the
following error messages are rendered in the browser through the validation
summary control.
·
The name must have at least a space between the names.
The name must be between 3 and 150 characters long.
·
The phone number must be between 7 and 10 characters long.
The phone number is not a valid phone number; it can be numbers only.
·
The email must have at least an @ sign and at least one decimal.
The domain of the email address was not determined.
The email address must be between 7 and 150 characters long.
·
The zip code does not exist in the allowable list of zip code
values; it must be in a range of 15601-15609.
The zip code entered is not five digits.
·
The authorization code must begin with the first letter of "A."
The authorization code is outside the range of valid values.
All of the new validations work, and as you enter in data,
it performs the validation correctly. This is to illustrate the power of the
validation framework in Enterprise Library 3.
Note: This code was created from the Community Technology
Preview (CTP) version of Enterprise Library 3. It may vary from the final release
of the product. Although this version of the Framework is very close to the
final, it may vary slightly from the final version.