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

Popular posts from this blog

apache - 504 Gateway Time-out The server didn't respond in time. How to fix it? -

c# - .net WebSocket: CloseOutputAsync vs CloseAsync -

c++ - How to properly scale qgroupbox title with stylesheet for high resolution display? -