1: @model DateTime?
2:
3: @using MyMvcApp.Properties
4:
5: <div id="dateTimePicker_@(ViewData.ModelMetadata.PropertyName)">
6: <script type="text/javascript" language="javascript"> 1:
2: //<![CDATA[
3: $(document).ready(function () { 4: var $div = $('#dateTimePicker_@(ViewData.ModelMetadata.PropertyName)'); 5:
6: $div.find('.date').datepicker({ altFormat: 'dd-mm-yy' }); 7: });
8:
9: function clearDateTimePicker_@(ViewData.ModelMetadata.PropertyName)() { 10: var $div = $('#dateTimePicker_@(ViewData.ModelMetadata.PropertyName)'); 11:
12: $div.find('.date').val(''); 13: $div.find('.hour').val('00'); 14: $div.find('.minute').val('00'); 15: }
16: //]]>
17:
</script>
7:
8: @* Date - should equal DatePicker.cshtml *@
9: @Html.TextBox("Value.Date", Model.HasValue ? Model.Value.Date.ToString() : string.Empty, new { @class = "date" })
10: <img alt="@Resources.SelectDate" src="../../../images/calendar.png" class="calendarIcon" />
11:
12: @* Time - should equal TimePicker.cshtml *@
13: @Html.DropDownList("Value.Hour", new SelectList(new[] { "00", "01", "02", "03", "04", "05", "06", "07", "08", "09", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", "20", "21", "22", "23" }, Model.HasValue ? Model.Value.Hour.ToString("D2") : "00"),
14: null, new { style = "width: auto; margin-left: 5px;", @class = "hour" })
15: :
16: @{
17: List<string> availableMinutes = new List<string>();
18: for (int minute = 0; minute < 60; minute += 1)
19: {
20: availableMinutes.Add(minute.ToString("D2"));
21: }
22:
23: @Html.DropDownList("Value.Minute", new SelectList(availableMinutes, Model.HasValue ? Model.Value.Minute.ToString("D2") : "00"),
24: null, new { style = "width: auto;", @class = "minute" });
25: }
26: <img alt="@Resources.SelectTime" src="../../../images/icon_clock_2.gif" style="margin-right: 5px" />
27: <input type="button" value="@Resources.Clear" class="ui-state-default" onclick="javascript:clearDateTimePicker_@(ViewData.ModelMetadata.PropertyName)()" />
28: </div>