FormExtensions Class

Visual Studio 2010

Represents support for HTML in an application.

System.Object
  System.Web.Mvc.Html.FormExtensions

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

'Declaration
<ExtensionAttribute> _
Public NotInheritable Class FormExtensions

The FormExtensions type exposes the following members.

  NameDescription
Public methodStatic memberBeginForm(HtmlHelper)Writes an opening <form> tag to the response. When the user submits the form, the request will be processed by an action method.
Public methodStatic memberBeginForm(HtmlHelper, Object)Writes an opening <form> tag to the response. When the user submits the form, the request will be processed by an action method.
Public methodStatic memberBeginForm(HtmlHelper, RouteValueDictionary)Writes an opening <form> tag to the response. When the user submits the form, the request will be processed by an action method.
Public methodStatic memberBeginForm(HtmlHelper, String, String)Writes an opening <form> tag to the response. When the user submits the form, the request will be processed by an action method.
Public methodStatic memberBeginForm(HtmlHelper, String, String, Object)Writes an opening <form> tag to the response. When the user submits the form, the request will be processed by an action method.
Public methodStatic memberBeginForm(HtmlHelper, String, String, FormMethod)Writes an opening <form> tag to the response. When the user submits the form, the request will be processed by an action method.
Public methodStatic memberBeginForm(HtmlHelper, String, String, RouteValueDictionary)Writes an opening <form> tag to the response. When the user submits the form, the request will be processed by an action method.
Public methodStatic memberBeginForm(HtmlHelper, String, String, Object, FormMethod)Writes an opening <form> tag to the response. When the user submits the form, the request will be processed by an action method.
Public methodStatic memberBeginForm(HtmlHelper, String, String, FormMethod, IDictionary(Of String, Object))Writes an opening <form> tag to the response. When the user submits the form, the request will be processed by an action method.
Public methodStatic memberBeginForm(HtmlHelper, String, String, FormMethod, Object)Writes an opening <form> tag to the response. When the user submits the form, the request will be processed by an action method.
Public methodStatic memberBeginForm(HtmlHelper, String, String, RouteValueDictionary, FormMethod)Writes an opening <form> tag to the response. When the user submits the form, the request will be processed by an action method.
Public methodStatic memberBeginForm(HtmlHelper, String, String, Object, FormMethod, Object)Writes an opening <form> tag to the response. When the user submits the form, the request will be processed by an action method.
Public methodStatic memberBeginForm(HtmlHelper, String, String, RouteValueDictionary, FormMethod, IDictionary(Of String, Object))Writes an opening <form> tag to the response. When the user submits the form, the request will be processed by an action method.
Public methodStatic memberBeginRouteForm(HtmlHelper, Object)Writes an opening <form> tag to the response. When the user submits the form, the request will be processed by the route target.
Public methodStatic memberBeginRouteForm(HtmlHelper, String)Writes an opening <form> tag to the response. When the user submits the form, the request will be processed by the route target.
Public methodStatic memberBeginRouteForm(HtmlHelper, RouteValueDictionary)Writes an opening <form> tag to the response. When the user submits the form, the request will be processed by the route target.
Public methodStatic memberBeginRouteForm(HtmlHelper, String, Object)Writes an opening <form> tag to the response. When the user submits the form, the request will be processed by the route target.
Public methodStatic memberBeginRouteForm(HtmlHelper, String, FormMethod)Writes an opening <form> tag to the response. When the user submits the form, the request will be processed by the route target.
Public methodStatic memberBeginRouteForm(HtmlHelper, String, RouteValueDictionary)Writes an opening <form> tag to the response. When the user submits the form, the request will be processed by the route target.
Public methodStatic memberBeginRouteForm(HtmlHelper, String, Object, FormMethod)Writes an opening <form> tag to the response. When the user submits the form, the request will be processed by the route target.
Public methodStatic memberBeginRouteForm(HtmlHelper, String, FormMethod, IDictionary(Of String, Object))Writes an opening <form> tag to the response. When the user submits the form, the request will be processed by the route target.
Public methodStatic memberBeginRouteForm(HtmlHelper, String, FormMethod, Object)Writes an opening <form> tag to the response. When the user submits the form, the request will be processed by the route target.
Public methodStatic memberBeginRouteForm(HtmlHelper, String, RouteValueDictionary, FormMethod)Writes an opening <form> tag to the response. When the user submits the form, the request will be processed by the route target.
Public methodStatic memberBeginRouteForm(HtmlHelper, String, Object, FormMethod, Object)Writes an opening <form> tag to the response. When the user submits the form, the request will be processed by the route target.
Public methodStatic memberBeginRouteForm(HtmlHelper, String, RouteValueDictionary, FormMethod, IDictionary(Of String, Object))Writes an opening <form> tag to the response. When the user submits the form, the request will be processed by the route target.
Public methodStatic memberEndFormRenders the closing </form> tag to the response.
Top

The FormExtensions class contains methods that extend the HtmlHelper class. Each extension method renders an HTML form element. The BeginForm method renders a form that will be handled by a controller action method. The BeginRouteForm method renders a form that will be handled by the URL that is identified by specified route parameters. The EndForm method renders the closing element for a form.

This example shows two ways to create the same form in ASP.NET 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" />

<% End Using%>

<br /><br />

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

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

<% form.EndForm()%>


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

ADD
Show: