I'm using ASP.NET MVC 3. I have my added my own custom validation attribute:
public class CustomAttribute : ValidationAttribute, IClientValidatable {
private readonly string _parameter1;
public CustomAttribute(string parameter1) {
_parameter1 = Global.Settings[parameter1];
}
protected override ValidationResult IsValid(object value, ValidationContext context) {
...
}
public IEnumerable<ModelClientValidationRule> GetClientValidationRules(ModelMetadata metadata, ControllerContext context) {
yield return new ModelClientValidationRule() {
ErrorMessage = FormatErrorMessage(metadata.DisplayName),
ValidationType = "custom",
ValidationParameters = { { "parameter1", _parameter1 } }
};
}
}
Notice how it implements IClientValidatable
. This renders the parameters1
setting as a HTML 5 data attribute into the field on the page.
The problem i have is the value of the setting can change but every time it changes it still renders the old value inside the data attribute. I'm guessing this is cached somewhere. Is there anyway to remove the cache?
I'd appreciate the help. Thanks