Date Range in Calendar Control
27 Aug 20261 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 less than the max date. If the values of the min or max properties are changed through code behind, then update the value property to be set within the specified range.
Otherwise, if the value is outside the specified date range and less than the min date, the value property will be updated with the min date. If the value is higher than the max date, the value property will be updated with the max date.
@Html.EJS().Calendar("element").Value(ViewBag.value).Min(ViewBag.minDate).Max(ViewBag.maxDate).Render()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();
}
}
}