Export (0) Print
Expand All

MvcForm Class

Represents an HTML form element in an MVC view.

Namespace:  System.Web.Mvc.Html
Assembly:  System.Web.Mvc (in System.Web.Mvc.dll)

public class MvcForm : IDisposable

A MvcForm instance is returned by both the BeginForm and BeginRouteForm extension methods of the HtmlHelper class.

This example shows two ways to create the same form in MVC. The first way uses the Using statement. The second way uses the MvcForm class directly.

<% using (Html.BeginForm("ProcessForm", "Home"))
   { %>

   Enter your name: <%= Html.TextBox("name") %>
   <input type="submit" value="Submit" />

<% } %>

<br /><br />

<% MvcForm form = Html.BeginForm("ProcessForm", "Home"); %>

       Enter your name: <%= Html.TextBox("name") %>
       <input type="submit" value="Submit" />

<% form.EndForm(); %>


System.Object
  System.Web.Mvc.Html.MvcForm

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

Community Additions

Show:
© 2014 Microsoft