How to access the Date and Time values entered from the Razor Page Model class in C#?

This is primarily about the DateTimePicker, but it also applies to most of the controls that I have tried to use so far. My problem is accessing the values entered into the DateTimePicker from the Page Model code when the Page is posted.

1 Reply

PK Prem Kumar Madhan Raj Syncfusion Team July 2, 2018 12:37 PM UTC

Hi Jim, 

Thanks for contacting Syncfusion Support. 

By default, whenever, a component is rendered by with id defined, the id attribute value will be considered as name attribute of the component. So, in order to get the value on post back, we need to set the name attribute value for the DateTimePicker component as same as the variable name of the model variable name as shown below. 

<ejs-datetimepicker id="datetime" name="Value" value="@Model.Value"></ejs-datetimepicker> 

For your convenience, we have attached a sample in the below link. Please check it. 


Regards, 

Prem Kumar M 


Loader.
Up arrow icon