Share via


HtmlHelper.GenerateForm Method

Definition

Renders a <form> start tag to the response. When the user submits the form, the action with name actionName will process the request.

protected:
 virtual Microsoft::AspNetCore::Mvc::Rendering::MvcForm ^ GenerateForm(System::String ^ actionName, System::String ^ controllerName, System::Object ^ routeValues, Microsoft::AspNetCore::Mvc::Rendering::FormMethod method, Nullable<bool> antiforgery, System::Object ^ htmlAttributes);
protected virtual Microsoft.AspNetCore.Mvc.Rendering.MvcForm GenerateForm (string actionName, string controllerName, object routeValues, Microsoft.AspNetCore.Mvc.Rendering.FormMethod method, bool? antiforgery, object htmlAttributes);
abstract member GenerateForm : string * string * obj * Microsoft.AspNetCore.Mvc.Rendering.FormMethod * Nullable<bool> * obj -> Microsoft.AspNetCore.Mvc.Rendering.MvcForm
override this.GenerateForm : string * string * obj * Microsoft.AspNetCore.Mvc.Rendering.FormMethod * Nullable<bool> * obj -> Microsoft.AspNetCore.Mvc.Rendering.MvcForm
Protected Overridable Function GenerateForm (actionName As String, controllerName As String, routeValues As Object, method As FormMethod, antiforgery As Nullable(Of Boolean), htmlAttributes As Object) As MvcForm

Parameters

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 using Object initializer syntax. Alternatively, an IDictionary<TKey,TValue> instance containing the route parameters.

method
FormMethod

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

antiforgery
Nullable<Boolean>

If true, <form> elements will include an antiforgery token. If false, suppresses the generation an <input> of type "hidden" with an antiforgery token. If null, <form> elements will include an antiforgery token only if method is not Get.

htmlAttributes
Object

An Object that contains the HTML attributes for the element. Alternatively, an IDictionary<TKey,TValue> instance containing the HTML attributes.

Returns

An MvcForm instance which renders the </form> end tag when disposed.

Remarks

In this context, "renders" means the method writes its output using Writer.

Applies to