public static MvcHtmlString AppLabel(this HtmlHelper htmlHelper, string text, object htmlAttributes = null) { var control = new RenderLabel(); control.Text = text; HtmlAttributes(control, htmlAttributes); return(MvcHtmlString.Create(control.ToString())); }
public static MvcHtmlString AppLabelFor <TModel, TProperty>(this HtmlHelper <TModel> htmlHelper, Expression <Func <TModel, TProperty> > expression, object htmlAttributes = null) { var control = new RenderLabel(); ModelMetadata metadata = ModelMetadata.FromLambdaExpression(expression, htmlHelper.ViewData); control.For = metadata.PropertyName; if (!string.IsNullOrEmpty(metadata.DisplayName)) { control.Text = metadata.DisplayName; } else { control.Text = metadata.PropertyName.Replace("_", " "); } HtmlAttributes(control, htmlAttributes); return(MvcHtmlString.Create(control.ToString())); }