1

I have a folder called "ModelMetaData.cs" where I have a class called "InspeccioModelMetaData.cs" with these code:

[DisplayName("Id")]
public string IdInspeccio { get; set; }
[DisplayName("Data de caducitat")]
public DateTime DataCaducitat { get; set; }

And the Model have these code:

[MetadataType(typeof(InspeccioModelMetaData))]
public partial class Inspeccio
{

...

public System.DateTime DataCaducitat { get; set; }

...

In the view when I use @Html.DisplayNameFor it works but when I use

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

it doesn't.

I have searched the solution by googling but nothing works for me...

Can someone helps me please?

Thanks!

NorbertFD
  • 51
  • 7

1 Answers1

1

Make sure that these metadata classes are in the same namespace as the model.