Created
June 3, 2013 23:10
-
-
Save timhobbs/5702256 to your computer and use it in GitHub Desktop.
Taken from http://coderj.net/asp-net-mvc-helper-for-creating-twitter-bootstrap-form-fields/ and put into a Gist (to show OP)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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