Search results

Prevent the Popup Close in ASP.NET Core DatePicker control

19 Oct 2021 / 1 minute to read

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

The following example demonstrates how to prevent the popup from closing.

Copied to clipboard
<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
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 HomeController: Controller
        public ActionResult sample()
            ViewBag.value = new DateTime(DateTime.Now.Year,DateTime.Now.Month,14);
            return View();