Search results

Prevent the popup close

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.

@Html.EJS().DatePicker("datepicker").Close("onClose").Placeholder("Choose a Date").Render()

    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();