The code looks like this:
@Html.LabelFor(m => m.FormModel.Position, Model.Company.DefaultEmployee.ToStringOrDefault())
And the HTML looks like this:
<label for="FormModel.Position" >Programmer</label>
("Programmer" is the string generated by the Model.Company.DefaultEmployee.ToStringOrDefault()
method)
I tried this:
@Html.LabelFor(m => m.FormModel.Position, Model.Company.DefaultEmployee.ToStringOrDefault(), new {id = "position-label"})
But it does not work.
This is what the Html extension looks like:
public static MvcHtmlString LabelFor<TModel, TValue>(this HtmlHelper<TModel> html, Expression<Func<TModel, TValue>> expression, string labelText, object htmlAttributes)
{
return LabelFor(html, expression, labelText, new RouteValueDictionary(htmlAttributes));
}