How does @Html.BeginForm() works?

后端 未结 4 1355
栀梦
栀梦 2020-12-05 14:19

I\'m very new to ASP.NET, just started the MVC tutorial today on asp.net. I got here http://www.asp.net/mvc/tutorials/mvc-4/getting-started-with-aspnet-mvc4/examining-the-ed

4条回答
  •  时光说笑
    2020-12-05 15:06

    When you call BeginForm() without any parameters it default to using the same controller/action used to render the current page. It assumes you'll have an action with the correct name on your controller that will accept postbacks (which you do). It uses the RouteValues to do this.

    It automatically binds each input control (by name) to the parameters of the action accepting the postback - or in your case, the properties of the object parameter for the action accepting the postback.

提交回复
热议问题