开发者

Would it be possible to change literals in the model below to reference values from an external file for localization or quick user changes?

Given users who change their minds a thousand times. How could I change the literals below to come from a config file or something similar?

namespace mvc3test.Models
{

    public class ChangePasswordModel
    {
        [Required]
        [DataType(DataType.Password)]
        [Display(Name = "Current password")]
        public string OldPassword { get; set; }

        [Required]
        [StringLength(100, ErrorMessage = "The {0} must be at least {2} characters long.", MinimumL开发者_运维百科ength = 6)]
        [DataType(DataType.Password)]
        [Display(Name = "New password")]
        public string NewPassword { get; set; }


These attributes(eg DisplayAttribute) have ResourceType and Name properties. These can be used with a Resource file to externalize the literals and thereby localizing and/or changing literals. Have a look at this example.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜