Search results

Getting started with ASP.NET Core Calendar control

25 Oct 2021 / 2 minutes to read

This section briefly explains how to include simple Calendar 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 Calendar control to the Application

Calendar control can be rendered by using the ejs-calendar 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 Calendar.

The following example shows a basic Calendar control.

Copied to clipboard
<ejs-calendar id="calendar"></ejs-calendar>

Running the above code will display the basic Calendar on the browser.

Setting the value within min and max dates

After rendering a simple Calendar control by following the above steps, configure the Calendar to set a value within a specific range using its value, min, and max properties.

Here the Calendar allows you to select a date within the range from 5th to 27th of this month.

Copied to clipboard
<ejs-calendar id="calendar" min="ViewBag.minDate" max="ViewBag.maxDate"></ejs-calendar>
Copied to clipboard
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;

namespace EJ2CoreSampleBrowser.Controllers
    public class CalendarController : Controller
        public ActionResult DateRange()
            ViewBag.minDate= new DateTime(DateTime.Now.Year,DateTime.Now.Month,05);
            ViewBag.maxDate = new DateTime(DateTime.Now.Year, DateTime.Now.Month, 27);
            return View();

See Also