Enabled Date Picker From Client Side

Hi,

I'm trying to enable  date picker but i've no idea how to do that, please help me.


 <div id="wrapper" class="col-lg-2">
                                @Html.EJS().DatePicker("NominationDate").Value(DateTime.Today).Format("dd MMM yyyy").Enabled(false).Render()
                            </div>


and i have button when user click that  , i want to enable the date picker

 
        document.getElementById("UnLockDay").addEventListener('click', function () {

                ...


              });



3 Replies

DL Deepa Loganathan Syncfusion Team October 1, 2018 05:27 AM UTC

Hi Rashal, 

Thanks for Contacting Syncfusion Support. 

We have investigated your query. You can enable the EJ2 DatePicker on clicking the Button control, by setting enabled property as true, dynamically by using DatePicker object instance. Please, find the code sample for achieving your requirement below. 

[datepicker.cshtml] 
@Html.EJS().DatePicker("NominationDate").Value(DateTime.Today).Format("dd MMM yyyy").Enabled(false).Render() 
 
@Html.EJS().Button("UnLockDay").Content("Success").Render() 
 
<script> 
    document.getElementById("UnLockDay").addEventListener('click', function () { 
        var DatePickerInstance = document.getElementById("NominationDate").ej2_instances[0]; 
        DatePickerInstance.enabled = true; 
    }); 
</script> 

Also, check out the following links to know more about EJ2 DatePicker and Button components in ASP.NET MVC. 

DatePicker: 
Button:  
 
Please, let us know if you need further assistance. 

Regards, 
Deepa L. 




RI Rishal October 1, 2018 07:30 AM UTC

Thank you so much. 



PR Piramanayagam Ramakrishnan Syncfusion Team October 1, 2018 09:54 AM UTC

Hi Rashal, 
 
You are most welcome and please get back to us if you need any other assistance. 
 
Regards, 
Piramanayagam R 


Loader.
Up arrow icon