It\'s possible to add a HTML title
attribute to an input tag like so:
@Html.TextBoxFor(model => model.Name, new { title = \"Customer name\" })
>
Custom html helper is probably the neatest solution.
public static MvcHtmlString SpanFor(this HtmlHelper helper, Expression> expression, object htmlAttributes = null)
{
var valueGetter = expression.Compile();
var value = valueGetter(helper.ViewData.Model);
var span = new TagBuilder("span");
span.MergeAttributes(new RouteValueDictionary(htmlAttributes));
if (value != null)
{
span.SetInnerText(value.ToString());
}
return MvcHtmlString.Create(span.ToString());
}
=>
@Html.SpanFor(model => model.Name, new { title = "Customer name" })