If you do not want to hardcode the message or embed it as a resource, the only approach left is to extend the attribute so that messages can be decided at runtime based on the locale used. Extending an attribute for this purpose can also help if you decide to fetch the message from the database or an external translation service.
In this recipe, we will modify the
UniqueUserValidator code so that it can generate locale-based custom messages. The custom messages will be fetched from an XML file using the logic developed in the previous recipe.
The following steps will guide you as you generate locale-based custom messages:
CustomValidation.slnin Visual Studio .NET 2012.