Advertisement
Guest User

Untitled

a guest
Feb 19th, 2019
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.64 KB | None | 0 0
  1. @model GWeb.Models.FilterModel
  2. @using (Html.BeginForm())
  3. {
  4. @Html.ValidationSummary(true)
  5. <fieldset>
  6. <legend>Search criteria</legend>
  7.  
  8. @(Html.Telerik().ComboBox()
  9. .Name("UserName")
  10. .BindTo(new SelectList(ViewBag.workerList as System.Collections.IEnumerable, "Id", "Desciption"))
  11. .Value(Model.UserName))
  12.  
  13. @(Html.Telerik().DatePicker()
  14. .Name("StartWork")
  15. .Value(Model.StartWork))
  16.  
  17. @(Html.Telerik().DatePicker()
  18. .Name("EndWork")
  19. .Value(Model.EndWork))
  20.  
  21. <input type="submit" value="Filter" />
  22.  
  23. </fieldset>
  24. }
  25. @{Html.RenderPartial("EmployeeList", (IEnumerable<GWeb.Entities.Work>)ViewBag.employeeList);}
  26.  
  27. <td>
  28. <a href="@Url.Action("Edit", "Admin", new { id = item.Id })">
  29. <img src="/Content/edit.png" alt="Edit" title="Edit" width="22" height="22" />
  30. </a>
  31.  
  32. public class FilterModel
  33. {
  34. public string UserName { get; set; }
  35. public DateTime? StartWork { get; set; }
  36. public DateTime? EndWork { get; set; }
  37. //...
  38. }
  39.  
  40. <form action="~/Search/Index" method="GET">
  41. ...
  42. <submit />
  43. </form>
  44.  
  45. class SearchController : Controller
  46. {
  47. public ActionResult Index(FilterModel model = null)
  48. {
  49. Session["SearchUrl"] = Request.UrlReferrer.ToString();
  50. var results = get page of results...
  51. return View(results);
  52. }
  53.  
  54. [HttpPost]
  55. public ActionResult Edit(EditModel model)
  56. {
  57. //update the model...
  58.  
  59. return Redirect(Session["SearchUrl"]);
  60. }
  61. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement