Taken from http://coderj.net/asp-net-mvc-helper-for-creating-twitter-bootstrap-form-fields/ and put into a Gist (to show OP)
namespace MySweetApp | |
{ | |
using System; | |
using System.Linq.Expressions; | |
using System.Text; | |
using System.Web; | |
using System.Web.Mvc; | |
using System.Web.Mvc.Html; | |
public static class FormHelpers | |
{ | |
public static HtmlString FormField(this HtmlHelper helper, Expression<Func> func) | |
{ | |
var result = new StringBuilder(); | |
result.Append(@"<div>"); | |
result.Append(helper.LabelFor(func, new { @class = "control-label" })); | |
result.Append(@"<div>"); | |
result.Append(helper.EditorFor(func)); | |
result.Append(@"</div></div>"); | |
return new HtmlString(result.ToString()); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment