Language specific error message for the Range attribute

Vote:
 

Hi!

I have declared a property that has an allowed range from 1 to 15. I would like to have a language specific error message but it fails the way I have done it... (I have declared the "/errormessages/invalidrange" in EditorHints.xml where I have also declared other error messages for the RegularExpression attribute which are working fine):    

    [Range(1, 15, ErrorMessage = "/errormessages/invalidrange")]
    [Display(
        GroupName = SystemTabNames.Content,
        Order = 110)]
    public virtual int NumberOfArticles { get; set; }

Any suggestions?

#73144
Jul 08, 2013 14:19
Vote:
 

I'm not sure and haven't investigated further why message localization of MVC model attributes didn't work at all locally but I came up with a solution where a message is looked up at runtime, + added support for unobtrusive client-side validation (probably a bit overkill as built-in support has to work..).

More details here: http://www.tech-fellow.lv/2013/05/localized-episerver-model-validation-attributes/

I haven't had chance to dig into - but if you resolve - please give a hint :)

#73157
Jul 08, 2013 20:29
This thread is locked and should be used for reference only. Please use the Episerver CMS 7 and earlier versions forum to open new discussions.
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.