I'm trying to create a helper that will make my form controls in the whole website
Here is what i use till now
@helper editorField(System.Linq.Expressions.Expression<Func<Model, String>> o)
{
<div class="form-group">
@Html.LabelFor(o, new { @class = "col-md-4 control-label" })
@Html.ValidationMessageFor(o, "", new { @class = "col-md-6 col-xs-12 text-errer" })
<div class="col-md-5">
@Html.TextBoxFor(o, new { @class = "form-control" })
</div>
</div>
}
And the way i use it is
@editorField(model => model.Name)
@editorField(model => model.Email)
@editorField(model => model.PhoneNumber)
this make it really easy to change the style and layout of the whole website in 1 place
Now here is the problem
I need to make helper for each Model and data type
Im looking for a way to make it work something like this
@helper editorField(object o)
{
<div class="form-group">
@Html.LabelFor(o, new { @class = "col-md-4 control-label" })
@Html.ValidationMessageFor(o, "", new { @class = "col-md-6 col-xs-12 text-errer" })
<div class="col-md-5">
@Html.TextBoxFor(o, new { @class = "form-control" })
</div>
</div>
}
and it should work for all Models and datatypes