Guest User

Untitled

a guest
Aug 13th, 2018
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.96 KB | None | 0 0
  1. MVC3 view rendering twice when I have Glimpse and use a MVC control toolkit DateTimeFor element
  2. @using LeaveTracker.Models
  3. @using LeaveTracker.Models.Leave
  4. @using MVCControlsToolkit.Controls
  5. @using MVCControlsToolkit.Controls.Validation
  6. @model LeaveTracker.Models.Leave.LeaveAllocation
  7.  
  8. @{
  9. ViewBag.Title = "Edit";
  10. Layout = "~/Views/Shared/_LayoutMaintenance.cshtml";
  11. }
  12.  
  13. @Html.AntiForgeryToken()
  14. <div class="page-header">
  15. <h1>
  16. Edit Leave Allocation
  17. @if (Model.ID > 0) { <small> @Model.TypeOfLeave.Name till @Model.AppliesUntil.ToString("dd/MM/yyyy")</small> }
  18. </h1>
  19. </div>
  20.  
  21. <div>
  22. @Html.ActionLink("Back to List", "Index")
  23. </div>
  24.  
  25. <link href="@Url.Content("~/Content/themes/base/jquery-ui.css")" rel="stylesheet" type="text/css" />
  26. <link href="@Url.Content("~/Content/themes/base/jquery.ui.datepicker.css")" rel="stylesheet" type="text/css" />
  27. <script src="@Url.Content("~/Scripts/jquery-ui-1.8.16.min.js")" type="text/javascript"></script>
  28. @Html.JQueryDatePickerGlobalizationScript("en-GB")
  29. <script src="@Url.Content("~/Scripts/jquery.validate.min.js")" type="text/javascript"></script>
  30. <script src="@Url.Content("~/Scripts/jquery.validate.unobtrusive.min.js")" type="text/javascript"></script>
  31. <script src="@Url.Content("~/Scripts/ValidationSetup.js")" type="text/javascript"></script>
  32. <script src="@Url.Content("~/Scripts/MVCControlToolkit.Controls-1.5.0.js")" type="text/javascript"></script>
  33.  
  34. @using (Html.BeginForm()) {
  35.  
  36. @Html.ValidationSummary(true)
  37.  
  38. <fieldset>
  39. <legend>Leave Allocation Details</legend>
  40.  
  41. @Html.HiddenFor(model => model.ID)
  42.  
  43. <div class="clearfix">
  44. @Html.LabelFor(model => model.TypeOfLeave)
  45. <div class="input">
  46. @Html.DropDownListFor(model => model.TypeOfLeave,
  47. LeaveFactory.GetAllLeaveTypes().Select(fl => new SelectListItem
  48. {
  49. Text = fl.Name,
  50. Value = fl.ID.ToString()
  51. }))
  52. <span class="help-inline">@Html.ValidationMessageFor(model => model.TypeOfLeave)</span>
  53. </div>
  54. </div>
  55.  
  56. <div class="clearfix">
  57. @Html.LabelFor(model => model.AppliesFrom)
  58. <div class="input">
  59. @Html.DateTimeFor(model => model.AppliesFrom, DateTime.Today, true).DateCalendar(
  60. inLine: false,
  61. calendarOptions: new CalendarOptions
  62. {
  63. ChangeYear = true,
  64. ChangeMonth = true
  65. })
  66. <span class="help-inline">@Html.ValidationMessageFor(model => model.AppliesFrom)</span>
  67. </div>
  68. </div>
  69.  
  70. <div class="clearfix">
  71. @Html.LabelFor(model => model.AppliesUntil)
  72. <div class="input">
  73. @Html.DateTimeFor(model => model.AppliesUntil, DateTime.Today, true).DateCalendar(
  74. inLine: false,
  75. calendarOptions: new CalendarOptions
  76. {
  77. ChangeYear = true,
  78. ChangeMonth = true
  79. })
  80. <span class="help-inline">@Html.ValidationMessageFor(model => model.AppliesUntil)</span>
  81. </div>
  82. </div>
  83.  
  84. <div class="clearfix">
  85. @Html.LabelFor(model => model.DefaultAllocation)
  86. <div class="input">
  87. @Html.EditorFor(model => model.DefaultAllocation)
  88. <span class="help-inline">@Html.ValidationMessageFor(model => model.DefaultAllocation)</span>
  89. </div>
  90. </div>
  91.  
  92. </fieldset>
  93.  
  94. <fieldset>
  95.  
  96. <legend>Leave Carried Over</legend>
  97.  
  98. <div class="clearfix">
  99. @Html.LabelFor(model => model.MaxCarriesOver)
  100. <div class="input">
  101. @Html.EditorFor(model => model.MaxCarriesOver)
  102. <span class="help-inline">@Html.ValidationMessageFor(model => model.MaxCarriesOver)</span>
  103. </div>
  104. </div>
  105.  
  106. <div class="clearfix">
  107. @Html.LabelFor(model => model.LeaveUseByDate)
  108. <div class="input">
  109. @Html.DateTimeFor(model => model.LeaveUseByDate, DateTime.Parse("01/01/1900"), true).DateCalendar(
  110. inLine: false,
  111. calendarOptions: new CalendarOptions
  112. {
  113. ChangeYear = true,
  114. ChangeMonth = true
  115. })
  116. <span class="help-inline">@Html.ValidationMessageFor(model => model.LeaveUseByDate)</span>
  117. <span class="help-block">The year on this field doesn't matter, only the month and day will be taken into account</span>
  118. </div>
  119. </div>
  120.  
  121. <div class="actions">
  122. @Html.ActionLink("Cancel", "Index", null, new { @class = "btn" })
  123. <input class="btn primary" type="submit" value='Save'>
  124. </div>
  125.  
  126. </fieldset>
  127. }
Add Comment
Please, Sign In to add comment