开发者

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

开发者 https://www.devze.com 2023-03-09 23:14 出处:网络
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?

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

精彩评论

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

关注公众号