c# - Pass value from view to controller using DisplayFor -
I want to give the controller the value of the model from the scene.
When I go to @ Html.TextBoxFor
, the value goes to the controller, but when I use @ Html.DisplayFor
, the value is in the controller null
is there.
View.cshtml
@using (Html.BeginForm ("EditView", "Home")) {@Html. TextBoxFor (model = & gt; model.Name) // The first method is @ Html.DisplayFor (model => model.Name) // The second method is & lt; Input type = "submit" value = "OK!" Class = "btn btn-success btn-sm" /> } Administrator
Public ActionSecult Edit View (Modellist Models) {Redirect Return Action ( "Index"); }
Basically, the controller value is received for the first time; But for the second time, it becomes null
how can I solve it?
@ html.DisplayFor
just display values in the view.
If you want to return the value to the controller on the poster, then you @ Html.HiddenFor
Comments
Post a Comment