Share via


FormExtensions Class

Represents support for HTML in an application.

Inheritance Hierarchy

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

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

Syntax

'Declaration
<ExtensionAttribute> _
Public NotInheritable Class FormExtensions
public static class FormExtensions
[ExtensionAttribute]
public ref class FormExtensions abstract sealed

The FormExtensions type exposes the following members.

Methods

  Name Description
Public methodStatic member BeginForm(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 member BeginForm(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 member BeginForm(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 member BeginForm(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 member BeginForm(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 member BeginForm(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 member BeginForm(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 member BeginForm(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 member BeginForm(HtmlHelper, String, String, FormMethod, IDictionary<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 member BeginForm(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 member BeginForm(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 member BeginForm(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 member BeginForm(HtmlHelper, String, String, RouteValueDictionary, FormMethod, IDictionary<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 member BeginRouteForm(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 member BeginRouteForm(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 member BeginRouteForm(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 member BeginRouteForm(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 member BeginRouteForm(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 member BeginRouteForm(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 member BeginRouteForm(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 member BeginRouteForm(HtmlHelper, String, FormMethod, IDictionary<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 member BeginRouteForm(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 member BeginRouteForm(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 member BeginRouteForm(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 member BeginRouteForm(HtmlHelper, String, RouteValueDictionary, FormMethod, IDictionary<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 member EndForm Renders the closing </form> tag to the response.

Top

Remarks

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.

Examples

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()%>
<% 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(); %>

Thread Safety

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

See Also

Reference

System.Web.Mvc.Html Namespace