Table of Contents

Class FormExtensions

Namespace
System.Web.Mvc.Html
Assembly
System.Web.Mvc.dll

Represents support for HTML in an application.

public static class FormExtensions
Inheritance
FormExtensions
Inherited Members

Methods

BeginForm(HtmlHelper)

Writes an opening <form> tag to the response. The form uses the POST method, and the request is processed by the action method for the view.

public static MvcForm BeginForm(this HtmlHelper htmlHelper)

Parameters

htmlHelper HtmlHelper

The HTML helper instance that this method extends.

Returns

MvcForm

An opening <form> tag.

BeginForm(HtmlHelper, object)

Writes an opening <form> tag to the response and includes the route values in the action attribute. The form uses the POST method, and the request is processed by the action method for the view.

public static MvcForm BeginForm(this HtmlHelper htmlHelper, object routeValues)

Parameters

htmlHelper HtmlHelper

The HTML helper instance that this method extends.

routeValues object

An object that contains the parameters for a route. The parameters are retrieved through reflection by examining the properties of the object. This object is typically created by using object initializer syntax.

Returns

MvcForm

An opening <form> tag.

BeginForm(HtmlHelper, string, string)

Writes an opening <form> tag to the response and sets the action tag to the specified controller and action. The form uses the POST method.

public static MvcForm BeginForm(this HtmlHelper htmlHelper, string actionName, string controllerName)

Parameters

htmlHelper HtmlHelper

The HTML helper instance that this method extends.

actionName string

The name of the action method.

controllerName string

The name of the controller.

Returns

MvcForm

An opening <form> tag.

BeginForm(HtmlHelper, string, string, object)

Writes an opening <form> tag to the response, and sets the action tag to the specified controller, action, and route values. The form uses the POST method.

public static MvcForm BeginForm(this HtmlHelper htmlHelper, string actionName, string controllerName, object routeValues)

Parameters

htmlHelper HtmlHelper

The HTML helper instance that this method extends.

actionName string

The name of the action method.

controllerName string

The name of the controller.

routeValues object

An object that contains the parameters for a route. The parameters are retrieved through reflection by examining the properties of the object. This object is typically created by using object initializer syntax.

Returns

MvcForm

An opening <form> tag.

BeginForm(HtmlHelper, string, string, object, FormMethod)

Writes an opening <form> tag to the response and sets the action tag to the specified controller, action, and route values. The form uses the specified HTTP method.

public static MvcForm BeginForm(this HtmlHelper htmlHelper, string actionName, string controllerName, object routeValues, FormMethod method)

Parameters

htmlHelper HtmlHelper

The HTML helper instance that this method extends.

actionName string

The name of the action method.

controllerName string

The name of the controller.

routeValues object

An object that contains the parameters for a route. The parameters are retrieved through reflection by examining the properties of the object. This object is typically created by using object initializer syntax.

method FormMethod

The HTTP method for processing the form, either GET or POST.

Returns

MvcForm

An opening <form> tag.

BeginForm(HtmlHelper, string, string, object, FormMethod, object)

Writes an opening <form> tag to the response and sets the action tag to the specified controller, action, and route values. The form uses the specified HTTP method and includes the HTML attributes.

public static MvcForm BeginForm(this HtmlHelper htmlHelper, string actionName, string controllerName, object routeValues, FormMethod method, object htmlAttributes)

Parameters

htmlHelper HtmlHelper

The HTML helper instance that this method extends.

actionName string

The name of the action method.

controllerName string

The name of the controller.

routeValues object

An object that contains the parameters for a route. The parameters are retrieved through reflection by examining the properties of the object. This object is typically created by using object initializer syntax.

method FormMethod

The HTTP method for processing the form, either GET or POST.

htmlAttributes object

An object that contains the HTML attributes to set for the element.

Returns

MvcForm

An opening <form> tag.

BeginForm(HtmlHelper, string, string, FormMethod)

Writes an opening <form> tag to the response and sets the action tag to the specified controller and action. The form uses the specified HTTP method.

public static MvcForm BeginForm(this HtmlHelper htmlHelper, string actionName, string controllerName, FormMethod method)

Parameters

htmlHelper HtmlHelper

The HTML helper instance that this method extends.

actionName string

The name of the action method.

controllerName string

The name of the controller.

method FormMethod

The HTTP method for processing the form, either GET or POST.

Returns

MvcForm

An opening <form> tag.

BeginForm(HtmlHelper, string, string, FormMethod, IDictionary<string, object>)

Writes an opening <form> tag to the response and sets the action tag to the specified controller and action. The form uses the specified HTTP method and includes the HTML attributes from a dictionary.

public static MvcForm BeginForm(this HtmlHelper htmlHelper, string actionName, string controllerName, FormMethod method, IDictionary<string, object> htmlAttributes)

Parameters

htmlHelper HtmlHelper

The HTML helper instance that this method extends.

actionName string

The name of the action method.

controllerName string

The name of the controller.

method FormMethod

The HTTP method for processing the form, either GET or POST.

htmlAttributes IDictionary<string, object>

An object that contains the HTML attributes to set for the element.

Returns

MvcForm

An opening <form> tag.

BeginForm(HtmlHelper, string, string, FormMethod, object)

Writes an opening <form> tag to the response and sets the action tag to the specified controller and action. The form uses the specified HTTP method and includes the HTML attributes.

public static MvcForm BeginForm(this HtmlHelper htmlHelper, string actionName, string controllerName, FormMethod method, object htmlAttributes)

Parameters

htmlHelper HtmlHelper

The HTML helper instance that this method extends.

actionName string

The name of the action method.

controllerName string

The name of the controller.

method FormMethod

The HTTP method for processing the form, either GET or POST.

htmlAttributes object

An object that contains the HTML attributes to set for the element.

Returns

MvcForm

An opening <form> tag.

BeginForm(HtmlHelper, string, string, RouteValueDictionary)

Writes an opening <form> tag to the response, and sets the action tag to the specified controller, action, and route values from the route value dictionary. The form uses the POST method.

public static MvcForm BeginForm(this HtmlHelper htmlHelper, string actionName, string controllerName, RouteValueDictionary routeValues)

Parameters

htmlHelper HtmlHelper

The HTML helper instance that this method extends.

actionName string

The name of the action method.

controllerName string

The name of the controller.

routeValues RouteValueDictionary

An object that contains the parameters for a route.

Returns

MvcForm

An opening <form> tag.

BeginForm(HtmlHelper, string, string, RouteValueDictionary, FormMethod)

Writes an opening <form> tag to the response, and sets the action tag to the specified controller, action, and route values from the route value dictionary. The form uses the specified HTTP method.

public static MvcForm BeginForm(this HtmlHelper htmlHelper, string actionName, string controllerName, RouteValueDictionary routeValues, FormMethod method)

Parameters

htmlHelper HtmlHelper

The HTML helper instance that this method extends.

actionName string

The name of the action method.

controllerName string

The name of the controller.

routeValues RouteValueDictionary

An object that contains the parameters for a route.

method FormMethod

The HTTP method for processing the form, either GET or POST.

Returns

MvcForm

An opening <form> tag.

BeginForm(HtmlHelper, string, string, RouteValueDictionary, FormMethod, IDictionary<string, object>)

Writes an opening <form> tag to the response, and sets the action tag to the specified controller, action, and route values from the route value dictionary. The form uses the specified HTTP method, and includes the HTML attributes from the dictionary.

public static MvcForm BeginForm(this HtmlHelper htmlHelper, string actionName, string controllerName, RouteValueDictionary routeValues, FormMethod method, IDictionary<string, object> htmlAttributes)

Parameters

htmlHelper HtmlHelper

The HTML helper instance that this method extends.

actionName string

The name of the action method.

controllerName string

The name of the controller.

routeValues RouteValueDictionary

An object that contains the parameters for a route.

method FormMethod

The HTTP method for processing the form, either GET or POST.

htmlAttributes IDictionary<string, object>

An object that contains the HTML attributes to set for the element.

Returns

MvcForm

An opening <form> tag.

BeginForm(HtmlHelper, RouteValueDictionary)

Writes an opening <form> tag to the response and includes the route values from the route value dictionary in the action attribute. The form uses the POST method, and the request is processed by the action method for the view.

public static MvcForm BeginForm(this HtmlHelper htmlHelper, RouteValueDictionary routeValues)

Parameters

htmlHelper HtmlHelper

The HTML helper instance that this method extends.

routeValues RouteValueDictionary

An object that contains the parameters for a route.

Returns

MvcForm

An opening <form> tag.

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 static MvcForm BeginRouteForm(this HtmlHelper htmlHelper, object routeValues)

Parameters

htmlHelper HtmlHelper

The HTML helper instance that this method extends.

routeValues object

An object that contains the parameters for a route. The parameters are retrieved through reflection by examining the properties of the object. This object is typically created by using object initializer syntax.

Returns

MvcForm

An opening <form> tag.

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 static MvcForm BeginRouteForm(this HtmlHelper htmlHelper, string routeName)

Parameters

htmlHelper HtmlHelper

The HTML helper instance that this method extends.

routeName string

The name of the route to use to obtain the form-post URL.

Returns

MvcForm

An opening <form> tag.

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 static MvcForm BeginRouteForm(this HtmlHelper htmlHelper, string routeName, object routeValues)

Parameters

htmlHelper HtmlHelper

The HTML helper instance that this method extends.

routeName string

The name of the route to use to obtain the form-post URL.

routeValues object

An object that contains the parameters for a route. The parameters are retrieved through reflection by examining the properties of the object. This object is typically created by using object initializer syntax.

Returns

MvcForm

An opening <form> tag.

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 static MvcForm BeginRouteForm(this HtmlHelper htmlHelper, string routeName, object routeValues, FormMethod method)

Parameters

htmlHelper HtmlHelper

The HTML helper instance that this method extends.

routeName string

The name of the route to use to obtain the form-post URL.

routeValues object

An object that contains the parameters for a route. The parameters are retrieved through reflection by examining the properties of the object. This object is typically created by using object initializer syntax.

method FormMethod

The HTTP method for processing the form, either GET or POST.

Returns

MvcForm

An opening <form> tag.

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 static MvcForm BeginRouteForm(this HtmlHelper htmlHelper, string routeName, object routeValues, FormMethod method, object htmlAttributes)

Parameters

htmlHelper HtmlHelper

The HTML helper instance that this method extends.

routeName string

The name of the route to use to obtain the form-post URL.

routeValues object

An object that contains the parameters for a route. The parameters are retrieved through reflection by examining the properties of the object. This object is typically created by using object initializer syntax.

method FormMethod

The HTTP method for processing the form, either GET or POST.

htmlAttributes object

An object that contains the HTML attributes to set for the element.

Returns

MvcForm

An opening <form> tag.

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 static MvcForm BeginRouteForm(this HtmlHelper htmlHelper, string routeName, FormMethod method)

Parameters

htmlHelper HtmlHelper

The HTML helper instance that this method extends.

routeName string

The name of the route to use to obtain the form-post URL.

method FormMethod

The HTTP method for processing the form, either GET or POST.

Returns

MvcForm

An opening <form> tag.

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 static MvcForm BeginRouteForm(this HtmlHelper htmlHelper, string routeName, FormMethod method, IDictionary<string, object> htmlAttributes)

Parameters

htmlHelper HtmlHelper

The HTML helper instance that this method extends.

routeName string

The name of the route to use to obtain the form-post URL.

method FormMethod

The HTTP method for processing the form, either GET or POST.

htmlAttributes IDictionary<string, object>

An object that contains the HTML attributes to set for the element.

Returns

MvcForm

An opening <form> tag.

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 static MvcForm BeginRouteForm(this HtmlHelper htmlHelper, string routeName, FormMethod method, object htmlAttributes)

Parameters

htmlHelper HtmlHelper

The HTML helper instance that this method extends.

routeName string

The name of the route to use to obtain the form-post URL.

method FormMethod

The HTTP method for processing the form, either GET or POST.

htmlAttributes object

An object that contains the HTML attributes to set for the element.

Returns

MvcForm

An opening <form> tag.

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 static MvcForm BeginRouteForm(this HtmlHelper htmlHelper, string routeName, RouteValueDictionary routeValues)

Parameters

htmlHelper HtmlHelper

The HTML helper instance that this method extends.

routeName string

The name of the route to use to obtain the form-post URL.

routeValues RouteValueDictionary

An object that contains the parameters for a route

Returns

MvcForm

An opening <form> tag.

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 static MvcForm BeginRouteForm(this HtmlHelper htmlHelper, string routeName, RouteValueDictionary routeValues, FormMethod method)

Parameters

htmlHelper HtmlHelper

The HTML helper instance that this method extends.

routeName string

The name of the route to use to obtain the form-post URL.

routeValues RouteValueDictionary

An object that contains the parameters for a route

method FormMethod

The HTTP method for processing the form, either GET or POST.

Returns

MvcForm

An opening <form> tag.

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 static MvcForm BeginRouteForm(this HtmlHelper htmlHelper, string routeName, RouteValueDictionary routeValues, FormMethod method, IDictionary<string, object> htmlAttributes)

Parameters

htmlHelper HtmlHelper

The HTML helper instance that this method extends.

routeName string

The name of the route to use to obtain the form-post URL.

routeValues RouteValueDictionary

An object that contains the parameters for a route

method FormMethod

The HTTP method for processing the form, either GET or POST.

htmlAttributes IDictionary<string, object>

An object that contains the HTML attributes to set for the element.

Returns

MvcForm

An opening <form> tag.

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 static MvcForm BeginRouteForm(this HtmlHelper htmlHelper, RouteValueDictionary routeValues)

Parameters

htmlHelper HtmlHelper

The HTML helper instance that this method extends.

routeValues RouteValueDictionary

An object that contains the parameters for a route

Returns

MvcForm

An opening <form> tag.

EndForm(HtmlHelper)

Renders the closing </form> tag to the response.

public static void EndForm(this HtmlHelper htmlHelper)

Parameters

htmlHelper HtmlHelper

The HTML helper instance that this method extends.