views:

434

answers:

3

Using web forms I know that you can only have one ASP.NET form on a page. I've done some implementations where I've used Javascript to add other forms to a page to support things like logon controls (that post back to Logon.aspx instead of the current page). I'm wondering if the single form per page is still present in ASP.NET MVC or if this restriction has been lifted.

+3  A: 

You'll probably want to use regular HTML forms in your MVC code with the action attribute pointing to the appropriate controller action. So you can have as many forms on the page as you want.

Gerald
+1  A: 

With ASP.NET MVC, you can actually use any presentation layer that you want. The default view engine, ASP.NET Web Forms, has the same restriction of one server-side form (runat="server") but with or without MVC, you could always use client-only forms.

With client-only forms (i,e., doesn't have runat='server' and therefore is parsed as part of an opaque LiteralControl parsed instead of an HtmlForm control), you cannot include any server-side controls that need to be in a server-side form.

Any code in the Web Form's markup (usually in <%= code blocks %>) that call the MVC framework's APIs (like <%= Html.Button() %>) are not parsed as ASP.NET web controls, so there is no restriction on where in the page those are used.

Mark Cidade
A: 

You can have as many Html forms as you see responsible to use.

MotoWilliams