Abhijeet
Abhijeet

Reputation: 13856

Placement of Html.BeginForm() in ASP.NET MVC

While in asp.net master page use to contain form control. I am not able to figure out, where is the correct location to place Html.BeginForm(). Is it Layout Page or the View.

Thank you for your help.

Upvotes: 0

Views: 344

Answers (2)

Alexander Taran
Alexander Taran

Reputation: 6725

Form element should wrap up your input elements and textarea's.
Thus if your inputs are in your layout or master page - you can have a form there.
But most of the time your forms are in your views, where you create or edit data.

Upvotes: 1

Oded
Oded

Reputation: 498972

You should place one in any one location that you need a form. This normally means inside a view, as you would want a different action on each page/form rather than the same one across the site.

The limitation of one form per page that webforms has does not exist in MVC - you can have more than one form per page.

Upvotes: 1

Related Questions