MvcForm Class
Visual Studio 2010
Represents an HTML form element in an MVC view.
Assembly: System.Web.Mvc (in System.Web.Mvc.dll)
The MvcForm type exposes the following members.
| Name | Description | |
|---|---|---|
![]() | MvcForm(HttpResponseBase) | Obsolete. Initializes a new instance of the MvcForm class using the specified HTTP response object. |
![]() | MvcForm(ViewContext) | Initializes a new instance of the MvcForm class using the specified view context. |
| Name | Description | |
|---|---|---|
![]() | Dispose() | Releases all resources that are used by the current instance of the MvcForm class. |
![]() | Dispose(Boolean) | Releases unmanaged and, optionally, managed resources used by the current instance of the MvcForm class. |
![]() | EndForm | Ends the form and disposes of all form resources. |
![]() | Equals | Determines whether the specified Object is equal to the current Object. (Inherited from Object.) |
![]() | Finalize | Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection. (Inherited from Object.) |
![]() | GetHashCode | Serves as a hash function for a particular type. (Inherited from Object.) |
![]() | GetType | Gets the Type of the current instance. (Inherited from Object.) |
![]() | MemberwiseClone | Creates a shallow copy of the current Object. (Inherited from Object.) |
![]() | ToString | Returns a string that represents the current object. (Inherited from Object.) |
A MvcForm instance is returned by both the BeginForm and BeginRouteForm extension methods of the HtmlHelper and AjaxHelper classes.
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(); %>
Community Additions
ADD
Show:
