InputDate
InputDate
Overview
Features
Sample
Description
This sample shows the basic usage of the InputDate control.
Source
IndexController.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
namespace MvcExplorer.Controllers
{
public partial class InputDateController : Controller
{
public ActionResult Index()
{
return View();
}
}
}
Index.cshtml
@{
var today = DateTime.Now.Date;
var minDate = new DateTime(today.Year, 1, 1);
var maxDate = new DateTime(today.Year, 12, 31);
}
@section Scripts{
<script>
function changeDate(sender, e) {
wijmo.Control.getControl("#idcCalendar").value = sender.value;
}
function weekBeforeChanged(sender, args) {
var inputDate = wijmo.Control.getControl('#idcInputDate');
inputDate.weeksBefore = sender.value;
}
function weekAfterChanged(sender, args) {
var inputDate = wijmo.Control.getControl('#idcInputDate');
inputDate.weeksAfter = sender.value;
}
function monthCountChanged(sender, args) {
var inputDate = wijmo.Control.getControl('#idcInputDate');
inputDate.monthCount = sender.value;
}
</script>
}
<p>
@(Html.C1().Calendar().Id("idcCalendar")
.Value(today).Min(minDate).Max(maxDate)
.Width(300)
)
</p>
<div>
<label>Select a date</label>
@(Html.C1().InputDate().Id("idcInputDate")
.Value(today).Min(minDate).Max(maxDate).OnClientValueChanged("changeDate")
)
</div>
<br />
<fieldset>
<legend style="margin:0;padding:5px;border-bottom-width:0;border-right-width:1px;width:auto">@Html.Raw(Resources.InputDate.WeekBeforeAfterHeader_Text0)</legend>
<label style="font-weight:normal;">@Html.Raw(Resources.InputDate.WeekBefore_Text0)</label>
@(Html.C1().InputNumber().Min(0).Max(10).Step(1).Value(0).Format("n0").OnClientValueChanged("weekBeforeChanged"))
<label style="font-weight: normal;margin-top: 1em;">@Html.Raw(Resources.InputDate.WeekAfter_Text0)</label>
@(Html.C1().InputNumber().Min(0).Max(10).Step(1).Value(0).Format("n0").OnClientValueChanged("weekAfterChanged"))
<label style="font-weight: normal;margin-top: 1em;">@Html.Raw(Resources.InputDate.MonthCount_Text0)</label>
@(Html.C1().InputNumber().Min(1).Max(5).Step(1).Value(1).Format("n0").OnClientValueChanged("monthCountChanged"))
</fieldset>
@section Description{
@Html.Raw(Resources.InputDate.Index_Text0)
}
Documentation