하나는 CustomerDetail.cshtml이고 다른 하나는 PAymentDetail.cshtml이며 하나의 컨트롤러 QuoteController.cs가 있습니다.
두 뷰 모두 제출 버튼이 있고 두 뷰에 대한 HTTPPOST 메서드는 QuoteController.cs에 있습니다.
[HttpPost]
public ActionResult CustomerDetail(FormCollection form)
{
}
[HttpPost]
public ActionResult PAymentDetail(FormCollection form)
{
}
이제 Payment details의 Submit 버튼을 클릭하면 PAymentDetail이 아닌 CustomerDetail의 HttpPost 메소드로 호출 / 라우팅됩니다.
누구든지 이것에 나를 도울 수 있습니까 ?? 내가 뭘 잘못하고 있니? 둘 다 양식 방법은 POST입니다.
PaymentDetail의 경우보기에서 다음을 사용합니다.
@using(Html.BeginForm("PAymentDetail","Quote",FormMethod.Post))
{
//Form element here
}
결과 html은
<form action="/Quote/PAymentDetail" method="post"></form>
고객 상세도 동일
@using(Html.BeginForm("CustomerDetail","Quote",FormMethod.Post))
{
//Form element here
}
도움이 되었기를 바랍니다. 동일한 컨트롤러에 두 개의 게시 메서드가있는 것은 이러한 메서드의 이름이 다른 한 문제가되지 않습니다.
FormCollection 이외의 더 나은 방법을 위해 이것을 권장합니다. 먼저 모델을 만듭니다.
public class LoginModel
{
public string UserName { get; set; }
public string Password { get; set; }
public bool RememberMe { get; set; }
public string ReturnUrl { get; set; }
}
그런 다음보기에서 :
@model LoginModel
@using (Html.BeginForm()) {
<fieldset>
<div class="editor-label">
@Html.LabelFor(model => model.UserName)
</div>
<div class="editor-field">
@Html.EditorFor(model => model.UserName)
//Insted of razor tag, you can create your own input, it must have the same name as the model property like below.
<input type="text" name="Username" id="Username"/>
</div>
<div class="editor-label">
@Html.LabelFor(model => model.Password)
</div>
<div class="editor-field">
@Html.EditorFor(model => model.Password)
</div>
<div class="editor-label">
@Html.CheckBoxFor(m => m.RememberMe)
</div>
</fieldset>
}
이러한 사용자 입력은 컨트롤러에 매핑됩니다.
[HttpPost]
public ActionResult Login(LoginModel model)
{
String username = model.Username;
//Other thing
}
행운을 빌어 요.
이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.
침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제
몇 마디 만하겠습니다