none
mvc3 labelfor subobject RRS feed

  • Question

  • i have two classes :

    public class foo{
      [Display(Name="Here is my bar")]
      public bar myBar;
    
      [Display(Name="Here is my name")]
      public string myName;
    
    }
    
    public class bar{
      ...
    }
    

    I have a view "chooseBar.cshtml" strongly typed of foo.

    If I put a @Html.LabelFor(model => model.myName) -> I see "Here is my name" in the label. But, if i put a @Html.LabelFor(model => model.myBar) -> I see only "myBar", not the expected "Here is my bar"

    How can I use the LabelFor for my subobject ?(i.e displaying "Here is my bar" instead of "myBar" in the label)

    Thanks for your answer.

    jeudi 21 juillet 2011 09:13

Réponses