C# 对.cshtml视图中的Html.begin工作有疑问吗?
我对C#相当陌生(我来自Java),对于.NET如何处理.cshtml文件中的表单,我有以下疑问 在名为Index.xshtml的视图中,我有类似的内容:C# 对.cshtml视图中的Html.begin工作有疑问吗?,c#,asp.net-mvc,razor,C#,Asp.net Mvc,Razor,我对C#相当陌生(我来自Java),对于.NET如何处理.cshtml文件中的表单,我有以下疑问 在名为Index.xshtml的视图中,我有类似的内容: @using (Html.BeginForm("Index", "Vulnerability", FormMethod.Post, new { id = "MyForm" })) { <div class="ui-field-contain"> <label for="Filter_CVE">
@using (Html.BeginForm("Index", "Vulnerability", FormMethod.Post, new { id = "MyForm" }))
{
<div class="ui-field-contain">
<label for="Filter_CVE">CVE:</label>
<input type ="text" data-mini="true" data-clear-btn="true" id="Filter_CVE" name="Filter.CVE" value="@Model.Filter.CVE" />
</div>
<div data-role="controlgrup" data-type="horizontal" data-mini="true">
<input type="reset" data-inline="true" data-mini="true" value="Reset" />
<input type="submit" data-inline="true" data-mini="true" value="Seach" data-icon="search" />
</div>
}
查看官方文件(此处:)我找不到我的情况
那么,前面的方法参数的含义是什么
我认为它们可能是:
- 索引:它代表页面名称吗?(我的视图名为**Index.xshtml)
- 漏洞:代表什么
- FormMethod.Post:我认为这指定表单发送是Post
- 新建{id=“MyForm”}:这是什么
标记将获得MyForm的id
假设您的漏洞控制器中有以下代码:
public ActionResult Index() {
}
表单会将HTML输入字段中输入的所有数据发送到索引操作(通过POST)索引:这是操作的名称
漏洞是控制器的名称
FormMethod.Post表示该表单是通过Post发送的
new{id=“MyForm”}是html属性,在本例中,
标记将获得MyForm的id
假设您的漏洞控制器中有以下代码:
public ActionResult Index() {
}
您的表单将把HTML输入字段中输入的所有数据发送到索引操作(通过POST)有一个
方法签名:
public static MvcForm BeginForm(
this HtmlHelper htmlHelper,
string actionName,
string controllerName,
FormMethod method,
Object htmlAttributes
)
- actionName
类型:System.String
操作方法的名称
- 控制器名称
类型:System.String
控制器的名称
- 方法
类型:System.Web.Mvc.FormMethod
用于处理表单的HTTP方法,GET或POST
- htmlAttributes
类型:System.Object
包含要为元素设置的HTML属性的对象。有一个
方法签名:
public static MvcForm BeginForm(
this HtmlHelper htmlHelper,
string actionName,
string controllerName,
FormMethod method,
Object htmlAttributes
)
- actionName
类型:System.String
操作方法的名称
- 控制器名称
类型:System.String
控制器的名称
- 方法
类型:System.Web.Mvc.FormMethod
用于处理表单的HTTP方法,GET或POST
- htmlAttributes
类型:System.Object
包含要为元素设置的HTML属性的对象。索引:这是您的视图
,将在控制器中表示为操作方法
漏洞:这是您的控制器
FormMethod.Post:设置表单
新建{id=“MyForm”}:这将设置表单的id,如索引中所示:这是您的视图
,将在控制器中作为操作方法表示
漏洞:这是您的控制器
FormMethod.Post:设置表单
new{id=“MyForm”}:这将设置表单的id,如