Skip to content

Instantly share code, notes, and snippets.

@mxmissile
Created July 21, 2014 22:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mxmissile/6a59527890e4be3d9213 to your computer and use it in GitHub Desktop.
Save mxmissile/6a59527890e4be3d9213 to your computer and use it in GitHub Desktop.
@Html.LabelWithInput(...)
public static HtmlTag LabelWithInput<T>(this HtmlHelper<T> helper, Expression<Func<T, object>> expression) where T : class
{
var generator = GetGenerator<T>();
var label = generator.LabelFor(expression, model: helper.ViewData.Model);
var input = generator.InputFor(expression, model: helper.ViewData.Model);
var div = new DivTag();
div.AddClass("form-group");
div.Append(label);
div.Append(input);
return div;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment