Prevent the popup close

24 Mar 20221 minute to read

To prevent the DatePicker popup from closing, use the preventDefault method from the PreventableEventArgs.

<ejs-datepicker id="datepicker" close="onClose" placeholder="Choose a Date"></ejs-datepicker>

   document.addEventListener('DOMContentLoaded', function () {
     var datepickerObject = document.getElementById("datepicker").ej2_instances[0];;
    function onClose (args) {
        // prevent the popup close
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 sample()
            ViewBag.value = new DateTime(DateTime.Now.Year,DateTime.Now.Month,14);
            return View();