Hi Kenneth Tang,
Good day to you.
We have checked your code snippet and the cause of the problem is ejs-for component model value is bind to value property. So, no need to bind value property again. By default, datetimepicker default value is Null, we suspect you have use DateTime datatype, the DateTime default value set (12/31/2000 00:00). So, use nullable DateTime type (DatetTime?) and pass the current date or null. please find the code snippet and demos for your reference.
<form method="post">
<div>
<ejs-datetimepicker id="JOIN_DATE" placeholder="Select a date and time" ejs-for="@Model.JOIN_DATE" value="@Model.JOIN_DATE"></ejs-datetimepicker>
</div>
<div>
<ejs-textbox id="GUID" name="GUID" placeholder="GUID" ejs-for="@Model.GUID"></ejs-textbox>
</div>
<div class="form-group">
<input type="submit" value="Create Session" class="btn btn-primary" />
</div>
</form> |
public class HomeController : Controller
{
Session valueObject = new Session();
public IActionResult Index()
{
valueObject.JOIN_DATE = DateTime.Now;
valueObject.GUID = "";
return View(valueObject);
}
[HttpPost]
public IActionResult Index(Session model)
{
valueObject.JOIN_DATE = model.JOIN_DATE;
return View(model);
}
} |
Please check the sample and get back to us if you need any further assistance.
Regards,
Ashokkumar B.