Date Range

14 Mar 20221 minute to read

Calendar provides an option to select a date value within a specified range by defining the min and max properties. The min date should always be lesser than the max date. If the value of min or max properties are changed through code behind, then update the value property to be set within the specified range. Or else, if the value is out of specified date range and less than min date, value property will be updated with min date or the value is higher than max date, value property will be updated with max date.

<ejs-calendar id="calendar" value="ViewBag.value" min="ViewBag.minDate" max="ViewBag.maxDate"></ejs-calendar>
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,07);
            ViewBag.maxDate = new DateTime(DateTime.Now.Year, DateTime.Now.Month, 27);
            ViewBag.value = new DateTime(DateTime.Now.Year, DateTime.Now.Month, 14);
            return View();