Advertisement
Guest User

Untitled

a guest
Nov 28th, 2014
181
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.97 KB | None | 0 0
  1. using (Ajax.BeginForm("MyAction", "MyController", null, new AjaxOptions
  2. {
  3. InsertionMode = InsertionMode.Replace,
  4. UpdateTargetId = "content",
  5. LoadingElementId = "loading"
  6. }))
  7. {
  8. @Html.ValidationSummary()
  9.  
  10. <div id="content">
  11. @Html.EditorFor(m => m.Panes, "EditorTemplates/PanesViewModel")
  12. </div>
  13. }
  14.  
  15. <fieldset>
  16. <div id="wrapper">
  17. <table>
  18. @Html.EditorFor(m => m.List, "EditorTemplates/ListViewModel")
  19. </table>
  20. </div>
  21.  
  22. <button type="submit">Submit</button>
  23. </fieldset>
  24.  
  25. @Html.EditorFor(m => m.Items, "EditorTemplates/ItemViewModel")
  26.  
  27. <tr>
  28. <td>@Html.EditorFor(m => m.FieldName)</td>
  29. </tr>
  30.  
  31. [HttpPost]
  32. public ActionResult MyAction(PanesViewModel model)
  33. {
  34. if (ModelState.IsValid)
  35. {
  36. // Do stuff
  37. return PartialView("EditorTemplates/PanesViewModel");
  38. }
  39.  
  40. // Should retain model state and display Validation Summary.
  41. return PartialView("EditorTemplates/PanesViewModel", model);
  42. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement