1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

Usage of StringLengthAttribute ErrorMessage

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

  1. #1

    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:

    It looks like this:

            [StringLength(100, ErrorMessage = "The {0} must be at least {2} characters long.", MinimumLength = 6)]
            [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