How to pass a textbox value from view to a controller in MVC 4?

后端 未结 5 1415
我在风中等你
我在风中等你 2021-02-13 23:56

Here i am fetching the value from database and showing it in a input field


and

5条回答
  •  深忆病人
    2021-02-14 00:49

    Try the following in your view to check the output from each. The first one updates when the view is called a second time. My controller uses the key ShowCreateButton and has the optional parameter _createAction with a default value - you can change this to your key/parameter

    @Html.TextBox("_createAction", null, new { Value = (string)ViewBag.ShowCreateButton })
    @Html.TextBox("_createAction", ViewBag.ShowCreateButton )
    @ViewBag.ShowCreateButton
    

提交回复
热议问题