Set the readonly

24 Mar 20221 minute to read

The following example demonstrates how to set readonly in DatePicker control. You can achieve this by using readonly property.

@Html.EJS().DatePicker("datepicker").Readonly(true).Value(ViewBag.value).Placeholder("Choose a Date").Render()
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();
        }
    }
}