I would like to rewrite this piece of code using the solution presented here: Html.TextBoxFor formatting or Html.EditorFor htmlAttributes?
<div class="input">
@Html.TextBoxFor(x => x.Name)
@MyFunc()
@Html.ValidationMessageFor(x => x.Name)
</div>
<br />
But, since the call to this template format has no parameters, how can I pass the lambda expression x => x.Name
to @Html.ValidationMessageFor
?
I have this parameter on the calling page and I need to send it to the EditorFor template page:
Calling page
@Html.EditorFor(m => m.Name)
Classical example EditorFor template page
@model System.DateTime?
@Html.TextBox("", Model.HasValue ? Model.Value.ToString("dd/MM/yyyy") : string.Empty, new { @class = "date-picker" })
Real example of EditorFor for this case???
<div class="input">
@Html.TextBoxFor(????????)
@MyFunc()
@Html.ValidationMessageFor(??????)
</div>
<br />