fork download
  1.  
  2. // Где происходит вставка паршиал вью
  3. @foreach (var post in Model.CompanyPosts)
  4. {
  5. <tr>
  6.  
  7. <div id='row_@i'>
  8. @Html.Action("DisplayInputForm", new { cp = post, num = i })
  9. </div>
  10. </tr>
  11.  
  12. {
  13. i++;
  14. }
  15. }
  16. // само паршил вью
  17. @using (@Ajax.BeginForm("Edit", "CompanyPosts", FormMethod.Post, new AjaxOptions() {UpdateTargetId = "row_"+Model.FormNumber, InsertionMode = InsertionMode.Replace}, new { role = "form", id = "form" + @Model.FormNumber }))
  18. {
  19. @Html.Hidden("FormNumber", Model.FormNumber)
  20. @Html.Hidden("CompanyPost.Id", Model.CompanyPost.Id)
  21. <td class="custom_cell">
  22. @Html.TextBox("CompanyPost.PostName", Model.CompanyPost.Post.Name, new { @class = "form-control input_in_cell", onchange = "return form" + @Model.FormNumber + ".submit()" })
  23. </td>
  24. <td class="custom_cell">
  25. @Html.TextBox("CompanyPost.Rate", Model.CompanyPost.Rate, new { @class = "form-control input_in_cell", onchange = "return form" + @Model.FormNumber + ".submit()" })
  26. </td>
  27. }
  28. // методы гет и пост паршиал вью
  29. public PartialViewResult DisplayInputForm(CompanyPosts cp, int num)
  30. {
  31. CompanyPostsInputViewModel model = new CompanyPostsInputViewModel()
  32. {
  33. CompanyPost = cp,
  34. FormNumber = num
  35. };
  36.  
  37. return PartialView(model);
  38. }
  39.  
  40. [HttpPost]
  41. public PartialViewResult Edit(CompanyPostsInputViewModel model)
  42. {
  43. if (ModelState.IsValid)
  44. {
  45. service.SaveCompanyPosts(model.CompanyPost);
  46. }
  47. return PartialView("DisplayInputForm", model);
  48. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cs(3,13): error CS1525: Unexpected symbol `foreach'
prog.cs(7,29): error CS1012: Too many characters in character literal
Compilation failed: 2 error(s), 0 warnings
stdout
Standard output is empty