Usage of StringLengthAttribute ErrorMessage

Discussion in 'C#' started by DmitryS, Jul 5, 2011.

  1. #1
    Hello,

    I'm trying to figure out the format of StringLengthAttribute.ErrorMessage. What are the parameters passed when formatting this string? Let's say I want to show a message like this (for password validation):

    [StringLength(100, ErrorMessage = "The password must be at least {0} characters", MinimumLength = 6)]

    Would it format correctly? Here's an example I don't understand:

    http://mvcmusicstore.codeplex.com/S...c5263ed#MvcMusicStore/Models/AccountModels.cs

    It looks like this:

    [Required]
            [StringLength(100, ErrorMessage = "The {0} must be at least {2} characters long.", MinimumLength = 6)]
            [DataType(DataType.Password)]
            [Display(Name = "New password")]
            public string NewPassword { get; set; }
    Code (markup):
    What is {0} and {1}? Where do I read up on this information?
     
    DmitryS, Jul 5, 2011 IP