DisplayName does not work in relationship

1

I have a model :

public class TalaoCode : ITalaoCode
    {
        [Key]
        public int TalaoCodeId { get; set; }

        [DisplayName("Equipe")]
        public int EquipeId { get; set; }

        [DisplayName("Equipe")]
        public virtual Equipe Equipe { get; set; }
}

See that I put the DisplayName attribute in both, but when it is called in the view created by%% default, it does not exist the text of Scanfolding and yes DisplayName

View created by Scanfolding

@Html.LabelFor(model => model.EquipeId, "EquipeId", new { @class = "control-label col-md-2" })

I have tried to use EquipeId but also to no avail. TeamId always appears

    
asked by anonymous 28.12.2016 / 13:57

1 answer

2

What happens is that you are specifying the parameter labelText , so what is in DisplayName will not be shown.

Change your LabelFor to

@Html.LabelFor(model => model.EquipeId, htmlAttributes: new { @class = "control-label" })
    
28.12.2016 / 14:06