Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- MVC3 view rendering twice when I have Glimpse and use a MVC control toolkit DateTimeFor element
- @using LeaveTracker.Models
- @using LeaveTracker.Models.Leave
- @using MVCControlsToolkit.Controls
- @using MVCControlsToolkit.Controls.Validation
- @model LeaveTracker.Models.Leave.LeaveAllocation
- @{
- ViewBag.Title = "Edit";
- Layout = "~/Views/Shared/_LayoutMaintenance.cshtml";
- }
- @Html.AntiForgeryToken()
- <div class="page-header">
- <h1>
- Edit Leave Allocation
- @if (Model.ID > 0) { <small> @Model.TypeOfLeave.Name till @Model.AppliesUntil.ToString("dd/MM/yyyy")</small> }
- </h1>
- </div>
- <div>
- @Html.ActionLink("Back to List", "Index")
- </div>
- <link href="@Url.Content("~/Content/themes/base/jquery-ui.css")" rel="stylesheet" type="text/css" />
- <link href="@Url.Content("~/Content/themes/base/jquery.ui.datepicker.css")" rel="stylesheet" type="text/css" />
- <script src="@Url.Content("~/Scripts/jquery-ui-1.8.16.min.js")" type="text/javascript"></script>
- @Html.JQueryDatePickerGlobalizationScript("en-GB")
- <script src="@Url.Content("~/Scripts/jquery.validate.min.js")" type="text/javascript"></script>
- <script src="@Url.Content("~/Scripts/jquery.validate.unobtrusive.min.js")" type="text/javascript"></script>
- <script src="@Url.Content("~/Scripts/ValidationSetup.js")" type="text/javascript"></script>
- <script src="@Url.Content("~/Scripts/MVCControlToolkit.Controls-1.5.0.js")" type="text/javascript"></script>
- @using (Html.BeginForm()) {
- @Html.ValidationSummary(true)
- <fieldset>
- <legend>Leave Allocation Details</legend>
- @Html.HiddenFor(model => model.ID)
- <div class="clearfix">
- @Html.LabelFor(model => model.TypeOfLeave)
- <div class="input">
- @Html.DropDownListFor(model => model.TypeOfLeave,
- LeaveFactory.GetAllLeaveTypes().Select(fl => new SelectListItem
- {
- Text = fl.Name,
- Value = fl.ID.ToString()
- }))
- <span class="help-inline">@Html.ValidationMessageFor(model => model.TypeOfLeave)</span>
- </div>
- </div>
- <div class="clearfix">
- @Html.LabelFor(model => model.AppliesFrom)
- <div class="input">
- @Html.DateTimeFor(model => model.AppliesFrom, DateTime.Today, true).DateCalendar(
- inLine: false,
- calendarOptions: new CalendarOptions
- {
- ChangeYear = true,
- ChangeMonth = true
- })
- <span class="help-inline">@Html.ValidationMessageFor(model => model.AppliesFrom)</span>
- </div>
- </div>
- <div class="clearfix">
- @Html.LabelFor(model => model.AppliesUntil)
- <div class="input">
- @Html.DateTimeFor(model => model.AppliesUntil, DateTime.Today, true).DateCalendar(
- inLine: false,
- calendarOptions: new CalendarOptions
- {
- ChangeYear = true,
- ChangeMonth = true
- })
- <span class="help-inline">@Html.ValidationMessageFor(model => model.AppliesUntil)</span>
- </div>
- </div>
- <div class="clearfix">
- @Html.LabelFor(model => model.DefaultAllocation)
- <div class="input">
- @Html.EditorFor(model => model.DefaultAllocation)
- <span class="help-inline">@Html.ValidationMessageFor(model => model.DefaultAllocation)</span>
- </div>
- </div>
- </fieldset>
- <fieldset>
- <legend>Leave Carried Over</legend>
- <div class="clearfix">
- @Html.LabelFor(model => model.MaxCarriesOver)
- <div class="input">
- @Html.EditorFor(model => model.MaxCarriesOver)
- <span class="help-inline">@Html.ValidationMessageFor(model => model.MaxCarriesOver)</span>
- </div>
- </div>
- <div class="clearfix">
- @Html.LabelFor(model => model.LeaveUseByDate)
- <div class="input">
- @Html.DateTimeFor(model => model.LeaveUseByDate, DateTime.Parse("01/01/1900"), true).DateCalendar(
- inLine: false,
- calendarOptions: new CalendarOptions
- {
- ChangeYear = true,
- ChangeMonth = true
- })
- <span class="help-inline">@Html.ValidationMessageFor(model => model.LeaveUseByDate)</span>
- <span class="help-block">The year on this field doesn't matter, only the month and day will be taken into account</span>
- </div>
- </div>
- <div class="actions">
- @Html.ActionLink("Cancel", "Index", null, new { @class = "btn" })
- <input class="btn primary" type="submit" value='Save'>
- </div>
- </fieldset>
- }
Add Comment
Please, Sign In to add comment