Guest User

Untitled

a guest
Jul 20th, 2018
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.96 KB | None | 0 0
  1. public class StudentModel
  2. {
  3. public IEnumerable<SelectListItem> NormalStudentsList { get; set; }
  4. public IEnumerable<SelectListItem> StudentsNoClassList { get; set; }
  5. public string[] NormalSelected { get; set; }
  6. public string[] NoClassSelected { get; set; }
  7. public string Save { get; set; }
  8. }
  9.  
  10. public ActionResult IndexStudents(Docent docent, int id, int klasgroepid)
  11. {
  12. var studentModel = new StudentModel
  13. {
  14. NormalStudentsList = docent.GeefStudentenNormaalList(id, klasgroepid),
  15. StudentsNoClassList = docent.GeefStudentenNoClassList(id, klasgroepid)
  16. };
  17.  
  18. return View(studentModel);
  19. }
  20.  
  21. [HttpPost, Authorize]
  22. public ActionResult IndexStudentsResult(StudentModel model, string add, string remove)
  23. {
  24. ModelState.Clear();
  25. (if! string.IsNullOrEmpty(add))
  26. //update database
  27. SaveState(model);
  28. return View(model);
  29. }
  30.  
  31. <%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage<ProjectenII.Models.Domain.StudentModel>"%>
  32.  
  33. <asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
  34. IndexStudents
  35. </asp:Content>
  36.  
  37. <asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
  38. <h2>IndexStudents</h2>
  39.  
  40. <%using (Html.BeginForm()) { %>
  41. <%=Html.ListBoxFor(model => model.NormalSelected, new MultiSelectList(Model.NormalStudentsList, "StudentNummer", "Naam", Model.NormalSelected), new { size = "6" }); %>
  42.  
  43. <input type="submit" name="add"
  44. id="add" value=">>" /><br />
  45. <%=Html.ListBoxFor(model => model.NoClassSelected, new MultiSelectList(Model.StudentsNoClassList, "StudentNummer", "Naam", Model.NoClassSelected)); %>
  46. <% } %>
  47.  
  48. <%=Html.HiddenFor(model => model.Save) %>
  49. <input type="submit" name="apply" id="apply" value="Save!" />
  50. </asp:Content>
Add Comment
Please, Sign In to add comment