When we post the form using below to Action Method, we can see the View Model values in Parameter.
@Html.EditorFor(model => model.Foo)
When we post the form using below to Action Method, we can't see the View Model values in Parameter.
@Html.DisplayFor(model => model.Foo)
So, in later case, w could us Hidden Fields. So, I think, w should not us DisplayFor
when it comes o post form values.
Question : Why DisplayFor
does not post values to Action Method? Can we discuss the internal mechanism for this ?
see the html rendering. does not have the attribute name
. or not an input tag. the form tag only send tag elements input, select, textarea,...
that have the attribute name
. For example:
<form...>
<input id="lastname" name="lastname" />
</form>
not this:
<form...>
<input id="lastname" />
</form>