Abstracting the RegularExpressionValidator’s ValidationExpression
The RegularExpressionValidator is one of the most useful validators that come standard with ASP .NET. The RegularExpressionValidator allows you to validate, on both client-side and server-side, whether the value of an associated input control matches the pattern specified in the ValidationExpression property. It isn't uncommon to see a web application littered with almost identical validation markup spread across multiple pages and controls.

Figure 1 – Using the built-in validator
The problem with this approach is code repetition. If an application contained 100 textboxes that only accepted alphanumeric data the code would contain the same ValidationExpression property hard-coded in multiple places. A better solution would be to abstract the ValidationExpression so that if there was a need to alter the regular expression it could be changed once from a central location.
This abstraction (factoring out the details) can be achieved by creating a new class that inherits from the RegularExpressionValidator class. By adding a few new properties such as MinLength, MaxLength, and a ValidatonType the code becomes easily reusable for all RegularExpressionValidators.

Figure 2 – Abstracting the regular expression
The GetValidationExpression helper method would get the regular expression (i.e. from the Web.config) by checking the supplied ValidationType (I used an Enum for this).
Usage is as follows:

Figure 3 - Usage
Hopefully this helps illustrate some ideas on keeping code cleaner, leaner and a little more maintainable.