I am trying to add a css class to Html.LabelFor on an EditorTemplate
@Html.LabelFor(model => model.Name, new { @class = \"myLabel\" })
my
I suspect that you forgot to bring the namespace in which you defined this LabelExtensions class in scope in the view. So for example if this class is defined inside the MyProject.Extensions
namespace:
namespace MyProject.Extensions
{
public static class LabelExtensions
{
...
}
}
make sure that you've brought this namespace into scope:
@using MyProject.Extensions
@model MyViewModel
...
@Html.LabelFor(model => model.Name, new { @class = "myLabel" })