How can I replace the Range values with Web.Config values in MVC3?
[Range(5, 20, ErrorMessage = "Initial Deposit should be between $5.00 and $20.00")
public decimal InitialDeposit { get; set; }
web.config:
<add key="MinBalance" value="5.00"/>
<add key="MaxDeposit" value="20.00"/>
You will need to create a custom attribute inheriting from
RangeAttributeand implementingIClientValidatable.Example usage:
The first example will return the default error message, and the second will return your custom error message. Both will use the range values defined in web.config.