답변:
ID가 추가되어야합니다.
ASP.NET MVC 5 이하 :
<% using (Html.BeginForm(null, null, FormMethod.Post, new { id = "signupform" }))
{ } %>
ASP.NET Core : 양식 에 태그 도우미를 사용 하여 id를 설정하기위한 이상한 구문을 피할 수 있습니다 .
<form asp-controller="Account" asp-action="Register" method="post" id="signupform" role="form"></form>
프로젝트에 코드를 추가 했으므로 더 편리합니다.
HTMLExtensions.cs :
namespace System.Web.Mvc.Html
{
public static class HtmlExtensions
{
public static MvcForm BeginForm(this HtmlHelper htmlHelper, string formId)
{
return htmlHelper.BeginForm(null, null, FormMethod.Post, new { id = formId });
}
public static MvcForm BeginForm(this HtmlHelper htmlHelper, string formId, FormMethod method)
{
return htmlHelper.BeginForm(null, null, method, new { id = formId });
}
}
}
MySignupForm.cshtml :
@using (Html.BeginForm("signupform"))
{
@* Some fields *@
}
에서 System.Web.Mvc.Html (에서 System.Web.Mvc.dll ) 양식을 시작는 다음과 같이 정의한다 : - 세부 사항
BeginForm (이 HtmlHelper htmlHelper, 문자열 actionName, 문자열
controllerName, 객체 routeValues, FormMethod 메소드, 객체 htmlAttributes)
다음과 같이 사용해야 함을 의미합니다.
Html.BeginForm (문자열 actionName, 문자열 controllerName, 객체 routeValues, FormMethod 메소드, 객체 htmlAttributes)
MVC 4에서 작동했습니다.
@using (Html.BeginForm(null, null, new { @id = string.Empty }, FormMethod.Post,
new { @id = "signupform" }))
{
<input id="TRAINER_LIST" name="TRAINER_LIST" type="hidden" value="">
<input type="submit" value="Create" id="btnSubmit" />
}