- Initialize DateTimePicker control to the Application
- Setting the min and max
- See Also
Contact Support
Getting Started
28 Feb 20222 minutes to read
This section briefly explains how to include a simple DateTimePicker control in your ASP.NET Core application. You can refer to ASP.NET Core Getting Started documentation page for system requirements, and configure common specifications.
Starting with v16.2.0.x, if you reference Syncfusion assemblies from trial setup or from the NuGet feed, you also have to include a license key in your projects. Please refer to this link to know about registering Syncfusion license key in your ASP.NET Core application to use our controls.
Initialize DateTimePicker control to the Application
DateTimePicker control can be rendered by using the ejs-datetimepicker
tag helper in ASP.NET Core application. Add the below simple code to your index.cshtml
page which is available within the Views/Home
folder, to initialize the DateTimePicker.
The following example shows a basic DateTimePicker control
<ejs-datetimepicker id="datetimepicker"></ejs-datetimepicker>
Running the above code will display the basic DateTimePicker on the browser.
Setting the min and max
The minimum and maximum date time can be defined with the help of min
and max
property. The following example demonstrates to set the min
and max
on initializing the DateTimePicker.
<ejs-datetimepicker id="datetimepicker" min="@ViewBag.minDate" max="@ViewBag.maxDate"></ejs-datetimepicker>
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
namespace EJ2CoreSampleBrowser.Controllers
{
public class HomeController : Controller
{
public ActionResult DateTimeRange()
{
ViewBag.minDate= new DateTime(2019,11,22, 12,00,00);
ViewBag.maxDate = new DateTime(2019, 11, 25, 05, 00, 00);
return View();
}
}
}