public static IHtmlString LabelFor <TModel, TR>(this HtmlHelpers <TModel> html, Expression <Func <TModel, TR> > prop, object htmlAttributes) where TModel : class { var label = HtmlTagBuilder.CreateLabelFor(prop, htmlAttributes); return(label != null ? new NonEncodedHtmlString(label.ToString()) : NonEncodedHtmlString.Empty); }
public void LabelForUsesDisplayNameIfFound() { var tag = HtmlTagBuilder.CreateLabelFor <LabelModel, string>(lm => lm.AnotherProperty, null); Assert.AreEqual("Another Property", tag.RawContent); }
public void LabelForUsesPropertyNameByDefault() { var tag = HtmlTagBuilder.CreateLabelFor <LabelModel, string>(lm => lm.SomeProperty, null); Assert.AreEqual("SomeProperty", tag.RawContent); }