TimePicker
Edit this docThe TimePicker HtmlHelper extension is a server-side wrapper for the Kendo UI TimePicker widget.
Getting Started
Here is how to configure a simple Kendo TimePicker:
Make sure you have followed all the steps from the Introduction help topic.
Create a new action method which renders the view:
public ActionResult Index()
{
return View();
}
Add a timepicker:
WebForms
<%: Html.Kendo().TimePicker()
.Name("timepicker") //The name of the timepicker is mandatory. It specifies the "id" attribute of the widget.
.Min(new DateTime(2010, 1, 1, 10, 0, 0)) //Set min time of the timepicker
.Max(new DateTime(2010, 1, 1, 20, 0, 0)) //Set min date of the timepicker
.Value(DateTime.Now) //Set the value of the timepicker
%>
Razor
@(Html.Kendo().TimePicker()
.Name("timepicker") //The name of the timepicker is mandatory. It specifies the "id" attribute of the widget.
.Min(new DateTime(2010, 1, 1, 10, 0, 0)) //Set min time of the timepicker
.Max(new DateTime(2010, 1, 1, 20, 0, 0)) //Set min date of the timepicker
.Value(DateTime.Now) //Set the value of the timepicker
)
You can reference an existing TimePicker instance via jQuery.data().
Once a reference has been established, you can use the API to control its behavior.
//Put this after your Kendo TimePicker for ASP.NET MVC declaration
<script>
$(function() {
// Notice that the Name() of the timepicker is used to get its client-side instance
var timepicker = $("#timepicker").data("kendoTimePicker");
});
</script>
You can subscribe to all events exposed by Kendo UI TimePicker:
<%: Html.Kendo().TimePicker()
.Name("timepicker")
.Events(e => e
.Open("timepicker_open")
.Close("timepicker_close")
.Change("timepicker_change")
)
%>
<script>
function timepicker_open() {
//Handle the open event
}
function timepicker_close() {
//Handle the close event
}
function timepicker_change() {
//Handle the change event
}
</script>
@(Html.Kendo().TimePicker()
.Name("timepicker")
.Events(e => e
.Open("timepicker_open")
.Close("timepicker_close")
.Change("timepicker_change")
)
)
<script>
function timepicker_open() {
//Handle the open event
}
function timepicker_close() {
//Handle the close event
}
function timepicker_change() {
//Handle the change event
}
</script>
@(Html.Kendo().TimePicker()
.Name("timepicker")
.Events(e => e
.Open(@<text>
function() {
//Handle the open event inline
}
</text>)
.Change(@<text>
function() {
//Handle the change event inline
}
</text>)
)
)
The TimePicker widget supports DateTime structure. You will need to convert DateTimeOffset into DatePicker in order to show time correctly.
By default ASP.NET MVC project uses jQuery validate framework, which does not provide support for internationalized dates.
In other words, every string which Date.parse cannot define as valid date will be reported as invalid. As extending open source libraries is beyond of our product,
you will need to resolve this issue manually - check this link for more information.
You can also use Kendo Validator, which supports validating internationalized dates.