저는 며칠 동안이 문제로 어려움을 겪었습니다. Ajax를 통해로드 된 부분 뷰이지만 Ajax.BeginForm()을 사용하더라도 Ajax를 통해 제출하지는 않습니다.Ajax.BeginForm()이 아약스를 통해 제출하지 않았습니다.
컨트롤러 :
<HttpGet()> _
Public Function PersonalDetailsEdit(PersonalInfo As DetailsViewModel.PersonalDetails) As PartialViewResult
Return PartialView(PersonalInfo)
End Function
<HttpPost()> _
<AjaxOnly()> _
Public Function PersonalDetailsEdit(formcollection As FormCollection, model As DetailsViewModel.PersonalDetails) As PartialViewResult
Return PartialView("PersonalDetails", model)
End Function
보기 :
@ModelType ASK.Everest.ViewModels.DetailsViewModel.PersonalDetails
@Using Ajax.BeginForm("PersonalDetailsUpdate", "Details", New AjaxOptions() With {
.InsertionMode=InsertionMode.Replace,
.UpdateTargetId = "PersonalDetailsSection",
.OnFailure = "alert('fail');"}, New With {.id="PersonalDetailsForm"})
@Html.ValidationSummary(True)
@<fieldset id="PersonalDetailsUpdate">
<table class="table table-striped ">
<tr>
<th class="display-label">
<input type="hidden" value="@Html.NameFor(Function(model) model.Title)" />
@Html.DisplayNameFor(Function(model) model.Title)
</th>
<th class="display-label">
<input type="hidden" value="@Html.NameFor(Function(model) model.FirstName)" />
@Html.DisplayNameFor(Function(model) model.FirstName)
</th>
<th class="display-label">
<input type="hidden" value="Surname" />
@Html.DisplayNameFor(Function(model) model.Surname)
</th>
</tr>
<tr>
<td class="display-field">
@Html.DisplayFor(Function(model) model.Title)
</td>
<td class="display-field">
@Html.DisplayFor(Function(model) model.FirstName)
</td>
<td class="display-field">
@Html.DisplayFor(Function(model) model.Surname)
</td>
</tr>
<tr>
<th>
</th>
<th class="display-label">
@Html.DisplayNameFor(Function(model) model.Gender)
</th>
<th class="display-label">
<input type="hidden" value="@Html.NameFor(Function(model) model.DOB)" />
@Html.DisplayNameFor(Function(model) model.DOB)
</th>
</tr>
<tr>
<td>
</td>
<td class="display-field">
@Html.DisplayFor(Function(model) model.Gender)
</td>
<td class="display-field">
@Html.DisplayFor(Function(model) model.DOB)
</td>
</tr>
<tr>
<th>
</th>
<th class="display-label" colspan="2">
@Html.DisplayNameFor(Function(model) model.IDNumber)
</th>
</tr>
<tr>
<td>
</td>
<td class="display-field" colspan="2">
@Html.DisplayFor(Function(model) model.IDNumber)
</td>
</tr>
<tr>
<th>
</th>
<th class="display-label">
@Html.DisplayNameFor(Function(model) model.MaritalStatus)
</th>
<th class="display-label">
@Html.DisplayNameFor(Function(model) model.Nationality)
</th>
</tr>
<tr>
<td>
</td>
<td class="display-field">
@Html.DisplayFor(Function(model) model.MaritalStatus)
</td>
<td class="display-field">
@Html.DisplayFor(Function(model) model.Nationality)
</td>
</tr>
</table>
@*@Html.ActionLink("Back to List", "Index")*@
<p class="pull-right">
<input type="submit" value="Save" />
</p>
</fieldset>
End Using
내 번들 :
bundles.Add(New ScriptBundle("~/bundles/ask").Include(
"~/Scripts/jquery-1.7.*",
"~/Scripts/jquery-ui*",
"~/Scripts/jquery.validate*",
"~/Scripts/jquery.unobtrusive*",
"~/Content/bootstrap/js/bootstrap.js"))
_Layout.vbtml :
<!DOCTYPE html>
<html lang="eng">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width" />
<title>@ViewData("Title")</title>
@Styles.Render("~/Content/css")
@RenderSection("styles", required:=False)
@Scripts.Render("~/bundles/modernizr")
@Scripts.Render("~/bundles/ask")
@RenderSection("scripts", required:=False)
</head>
<body>
@RenderBody()
</body>
</html>
많은 좌절 후 포기하고이 같은 클라이언트 측에서 MVVM와 JQuery와 + 마네의 길을 가기로 결정 : 이제
<script type="text/javascript">
var data = @Html.Raw(Json.Encode(Model)) ;
var PersonalDetailsVM = ko.mapping.fromJS(data);
ko.applyBindings(PersonalDetailsVM, $('section#PersonalDetails')[0]);
</script>
난 그냥 JSON/MVC 날짜 변환과 사투를 벌인거야 - 내가 MVC4이 줄 알았는데 기본적으로 JSON.NET을 사용 하시겠습니까? 번거롭다면 또 다른 질문을 게시 할 것입니다.
덕분에, 난 그냥 많은 좌절 후 순수 JQuery와 + KnockoutJS의 경로를 이동하기로 결정했습니다. – sw00