Search results

Open the DatePicker popup upon focusing input of DatePicker in ASP.NET MVC DatePicker control

You can open the DatePicker popup on input focus by calling the show method in the input focus event.

The following example demonstrates how to open the DatePicker popup when the input is focused.

razor
openpopup.cs
@Html.EJS().DatePicker("datepicker").Focus("onFocus")..Width("300px").Placeholder("Choose a Date").Render()

<script>
    function onFocus(args) {
        var datepickerObject = document.getElementById("datepicker").ej2_instances[0];
        datepickerObject.show()
    }
</script>
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();
        }
    }
}

Output be like the below.

datepicker