mvc5 html.beginform,FormExtensions.BeginForm Method (System.Web.Mvc.Html) | Microsoft Docs

本文详细介绍了ASP.NET MVC框架中HtmlHelper的BeginForm方法的各种重载形式,用于创建HTML表单并指定HTTP方法(GET或POST)、控制器、操作、路由值和HTML属性。这些方法用于构建动态Web应用中表单的基本结构,帮助处理用户提交的请求。
摘要由CSDN通过智能技术生成

FormExtensions.BeginForm Method

Definition

Assembly:System.Web.Mvc.dll

Package:Microsoft.AspNet.Mvc v5.2.6

In this article

Overloads

Writes an opening

tag to the response. The form uses the POST method, and the request is processed by the action method for the view.

Writes an opening

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.

Writes an opening

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.

Writes an opening

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.

Writes an opening

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.

Writes an opening

tag to the response and sets the action tag to the specified controller, action, and route values. The form uses the specified HTTP method.

Writes an opening

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.

Writes an opening

tag to the response and sets the action tag to the specified controller and action. The form uses the specified HTTP method.

Writes an opening

tag to the response, and sets the action tag to the specified controller, action, and route values. The form uses the POST method.

Writes an opening

tag to the response and sets the action tag to the specified controller and action. The form uses the POST method.

Writes an opening

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.

Writes an opening

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.

Writes an opening

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.

BeginForm(HtmlHelper)

Writes an opening

tag to the response. The form uses the POST method, and the request is processed by the action method for the view.

public static System.Web.Mvc.Html.MvcForm BeginForm (this System.Web.Mvc.HtmlHelper htmlHelper);

static member BeginForm : System.Web.Mvc.HtmlHelper -> System.Web.Mvc.Html.MvcForm

Public Function BeginForm (htmlHelper As HtmlHelper) As MvcForm

Parameters

htmlHelper

The HTML helper instance that this method extends.

Returns

An opening

tag.

Applies to

BeginForm(HtmlHelper, String, String, Object, FormMethod, Object)

Writes an opening

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 System.Web.Mvc.Html.MvcForm BeginForm (this System.Web.Mvc.HtmlHelper htmlHelper, string actionName, string controllerName, object routeValues, System.Web.Mvc.FormMethod method, object htmlAttributes);

static member BeginForm : System.Web.Mvc.HtmlHelper * string * string * obj * System.Web.Mvc.FormMethod * obj -> System.Web.Mvc.Html.MvcForm

Public Function BeginForm (htmlHelper As HtmlHelper, actionName As String, controllerName As String, routeValues As Object, method As FormMethod, htmlAttributes As Object) As MvcForm

Parameters

htmlHelper

The HTML helper instance that this method extends.

actionName

The name of the action method.

controllerName

The name of the controller.

routeValues

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.

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

htmlAttributes

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

Returns

An opening

tag.

Applies to

BeginForm(HtmlHelper, String, String, RouteValueDictionary, FormMethod)

Writes an opening

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 System.Web.Mvc.Html.MvcForm BeginForm (this System.Web.Mvc.HtmlHelper htmlHelper, string actionName, string controllerName, System.Web.Routing.RouteValueDictionary routeValues, System.Web.Mvc.FormMethod method);

static member BeginForm : System.Web.Mvc.HtmlHelper * string * string * System.Web.Routing.RouteValueDictionary * System.Web.Mvc.FormMethod -> System.Web.Mvc.Html.MvcForm

Public Function BeginForm (htmlHelper As HtmlHelper, actionName As String, controllerName As String, routeValues As RouteValueDictionary, method As FormMethod) As MvcForm

Parameters

htmlHelper

The HTML helper instance that this method extends.

actionName

The name of the action method.

controllerName

The name of the controller.

An object that contains the parameters for a route.

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

Returns

An opening

tag.

Applies to

BeginForm(HtmlHelper, String, String, FormMethod, Object)

Writes an opening

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 System.Web.Mvc.Html.MvcForm BeginForm (this System.Web.Mvc.HtmlHelper htmlHelper, string actionName, string controllerName, System.Web.Mvc.FormMethod method, object htmlAttributes);

static member BeginForm : System.Web.Mvc.HtmlHelper * string * string * System.Web.Mvc.FormMethod * obj -> System.Web.Mvc.Html.MvcForm

Public Function BeginForm (htmlHelper As HtmlHelper, actionName As String, controllerName As String, method As FormMethod, htmlAttributes As Object) As MvcForm

Parameters

htmlHelper

The HTML helper instance that this method extends.

actionName

The name of the action method.

controllerName

The name of the controller.

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

htmlAttributes

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

Returns

An opening

tag.

Applies to

BeginForm(HtmlHelper, String, String, FormMethod, IDictionary)

Writes an opening

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 System.Web.Mvc.Html.MvcForm BeginForm (this System.Web.Mvc.HtmlHelper htmlHelper, string actionName, string controllerName, System.Web.Mvc.FormMethod method, System.Collections.Generic.IDictionary htmlAttributes);

static member BeginForm : System.Web.Mvc.HtmlHelper * string * string * System.Web.Mvc.FormMethod * System.Collections.Generic.IDictionary -> System.Web.Mvc.Html.MvcForm

Public Function BeginForm (htmlHelper As HtmlHelper, actionName As String, controllerName As String, method As FormMethod, htmlAttributes As IDictionary(Of String, Object)) As MvcForm

Parameters

htmlHelper

The HTML helper instance that this method extends.

actionName

The name of the action method.

controllerName

The name of the controller.

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

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

Returns

An opening

tag.

Applies to

BeginForm(HtmlHelper, String, String, Object, FormMethod)

Writes an opening

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 System.Web.Mvc.Html.MvcForm BeginForm (this System.Web.Mvc.HtmlHelper htmlHelper, string actionName, string controllerName, object routeValues, System.Web.Mvc.FormMethod method);

static member BeginForm : System.Web.Mvc.HtmlHelper * string * string * obj * System.Web.Mvc.FormMethod -> System.Web.Mvc.Html.MvcForm

Public Function BeginForm (htmlHelper As HtmlHelper, actionName As String, controllerName As String, routeValues As Object, method As FormMethod) As MvcForm

Parameters

htmlHelper

The HTML helper instance that this method extends.

actionName

The name of the action method.

controllerName

The name of the controller.

routeValues

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.

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

Returns

An opening

tag.

Applies to

BeginForm(HtmlHelper, String, String, RouteValueDictionary, FormMethod, IDictionary)

Writes an opening

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 System.Web.Mvc.Html.MvcForm BeginForm (this System.Web.Mvc.HtmlHelper htmlHelper, string actionName, string controllerName, System.Web.Routing.RouteValueDictionary routeValues, System.Web.Mvc.FormMethod method, System.Collections.Generic.IDictionary htmlAttributes);

static member BeginForm : System.Web.Mvc.HtmlHelper * string * string * System.Web.Routing.RouteValueDictionary * System.Web.Mvc.FormMethod * System.Collections.Generic.IDictionary -> System.Web.Mvc.Html.MvcForm

Public Function BeginForm (htmlHelper As HtmlHelper, actionName As String, controllerName As String, routeValues As RouteValueDictionary, method As FormMethod, htmlAttributes As IDictionary(Of String, Object)) As MvcForm

Parameters

htmlHelper

The HTML helper instance that this method extends.

actionName

The name of the action method.

controllerName

The name of the controller.

An object that contains the parameters for a route.

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

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

Returns

An opening

tag.

Applies to

BeginForm(HtmlHelper, String, String, FormMethod)

Writes an opening

tag to the response and sets the action tag to the specified controller and action. The form uses the specified HTTP method.

public static System.Web.Mvc.Html.MvcForm BeginForm (this System.Web.Mvc.HtmlHelper htmlHelper, string actionName, string controllerName, System.Web.Mvc.FormMethod method);

static member BeginForm : System.Web.Mvc.HtmlHelper * string * string * System.Web.Mvc.FormMethod -> System.Web.Mvc.Html.MvcForm

Public Function BeginForm (htmlHelper As HtmlHelper, actionName As String, controllerName As String, method As FormMethod) As MvcForm

Parameters

htmlHelper

The HTML helper instance that this method extends.

actionName

The name of the action method.

controllerName

The name of the controller.

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

Returns

An opening

tag.

Applies to

BeginForm(HtmlHelper, String, String, Object)

Writes an opening

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 System.Web.Mvc.Html.MvcForm BeginForm (this System.Web.Mvc.HtmlHelper htmlHelper, string actionName, string controllerName, object routeValues);

static member BeginForm : System.Web.Mvc.HtmlHelper * string * string * obj -> System.Web.Mvc.Html.MvcForm

Public Function BeginForm (htmlHelper As HtmlHelper, actionName As String, controllerName As String, routeValues As Object) As MvcForm

Parameters

htmlHelper

The HTML helper instance that this method extends.

actionName

The name of the action method.

controllerName

The name of the controller.

routeValues

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

An opening

tag.

Applies to

BeginForm(HtmlHelper, String, String)

Writes an opening

tag to the response and sets the action tag to the specified controller and action. The form uses the POST method.

public static System.Web.Mvc.Html.MvcForm BeginForm (this System.Web.Mvc.HtmlHelper htmlHelper, string actionName, string controllerName);

static member BeginForm : System.Web.Mvc.HtmlHelper * string * string -> System.Web.Mvc.Html.MvcForm

Public Function BeginForm (htmlHelper As HtmlHelper, actionName As String, controllerName As String) As MvcForm

Parameters

htmlHelper

The HTML helper instance that this method extends.

actionName

The name of the action method.

controllerName

The name of the controller.

Returns

An opening

tag.

Applies to

BeginForm(HtmlHelper, RouteValueDictionary)

Writes an opening

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 System.Web.Mvc.Html.MvcForm BeginForm (this System.Web.Mvc.HtmlHelper htmlHelper, System.Web.Routing.RouteValueDictionary routeValues);

static member BeginForm : System.Web.Mvc.HtmlHelper * System.Web.Routing.RouteValueDictionary -> System.Web.Mvc.Html.MvcForm

Public Function BeginForm (htmlHelper As HtmlHelper, routeValues As RouteValueDictionary) As MvcForm

Parameters

htmlHelper

The HTML helper instance that this method extends.

An object that contains the parameters for a route.

Returns

An opening

tag.

Applies to

BeginForm(HtmlHelper, Object)

Writes an opening

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 System.Web.Mvc.Html.MvcForm BeginForm (this System.Web.Mvc.HtmlHelper htmlHelper, object routeValues);

static member BeginForm : System.Web.Mvc.HtmlHelper * obj -> System.Web.Mvc.Html.MvcForm

Public Function BeginForm (htmlHelper As HtmlHelper, routeValues As Object) As MvcForm

Parameters

htmlHelper

The HTML helper instance that this method extends.

routeValues

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

An opening

tag.

Applies to

BeginForm(HtmlHelper, String, String, RouteValueDictionary)

Writes an opening

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 System.Web.Mvc.Html.MvcForm BeginForm (this System.Web.Mvc.HtmlHelper htmlHelper, string actionName, string controllerName, System.Web.Routing.RouteValueDictionary routeValues);

static member BeginForm : System.Web.Mvc.HtmlHelper * string * string * System.Web.Routing.RouteValueDictionary -> System.Web.Mvc.Html.MvcForm

Public Function BeginForm (htmlHelper As HtmlHelper, actionName As String, controllerName As String, routeValues As RouteValueDictionary) As MvcForm

Parameters

htmlHelper

The HTML helper instance that this method extends.

actionName

The name of the action method.

controllerName

The name of the controller.

An object that contains the parameters for a route.

Returns

An opening

tag.

Applies to

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值