I have param "min_payed" in web.config.
And I have model
public class Pay
{
[Required]
[Range(10,99999999)]
public Decimal Cost { get; set; }
}
min value I need get from web.config
I have param "min_payed" in web.config.
And I have model
public class Pay
{
[Required]
[Range(10,99999999)]
public Decimal Cost { get; set; }
}
min value I need get from web.config
You could write a custom range attribute that will read its min and max values from the <appSettings>
section of the config file:
public class ConfigBasedRangeAttribute : RangeAttribute
{
public ConfigBasedRangeAttribute():
base(GetConfigValue("min"), GetConfigValue("max"))
{
}
private static int GetConfigValue(string key)
{
return int.Parse(ConfigurationManager.AppSettings["key"]);
}
}
and then decorate your model with it:
public class Pay
{
[Required]
[ConfigBasedRange]
public Decimal Cost { get; set; }
}
I'm afraid you can't. You'll have to either implement IValidatableObject (and IClientValidatable for the clientside) or create your own dataannotation that checks the configuration file.