Search results

Date Range

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.

The following example allows you to select a date within the range of 7th to 27th days in a month.

tagHelper
daterange.cs
<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;

// For more information on enabling MVC for empty projects, visit https://go.microsoft.com/fwlink/?LinkID=397860

namespace EJ2CoreSampleBrowser.Controllers
{
    public partial class CalendarController : Controller
    {
        // GET: /<controller>/
        public IActionResult 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();
        }
    }
}