首页 > 代码库 > @using (Html.BeginForm())参数示例

@using (Html.BeginForm())参数示例

1、指定表单提交方式和路径等

 @using (Html.BeginForm("Index", "Home", FormMethod.Get, new { name = "nbform", id = "nbform" }))

2、指定表单提交为数据方式

 @using (Html.BeginForm("ImportExcel", "Stock", FormMethod.Post, new { enctype = "multipart/form-data" }))

 注意, 有时候要加{id=1}不然在点击超过第一页的索引时form后面会自动加上当前页的索引,如果此时再搜索则可能会出来“超出索引值”的错误提示
       @using (Html.BeginForm("Index", null, new { id = 1 }, FormMethod.Get))

3、下面的操作可以防止提交链接后面自带参数

@using (Html.BeginForm("AddDIYBillOfLading", "BillOfLading", new { id ="" }, FormMethod.Post, new { name = "myform", id = "myform" }))

即,RouteValues的id=""

@using (Html.BeginForm())参数示例