Set Date Time Picker Value

I am attempting to update my "Updated" timestamp field in the database when a save is made on the Edit form. I have a Date/Time picker that was generated during the original app creation. I can set the default value when the page is loaded. However, this doesn't appear to be saved to the database on submit. For whatever reason, it still retains the original value that was in the database. I don't see a Value property for the Date/Time picker element. So I am unsure how to accomplish this.

I'd prefer to have the date/time generated when the save is performed as the page load may not reflect when the change was actually submitted. I attempted to set the "Updated" property prior to the submit event, but this does not appear to work either.

Any thoughts?

How did you set the property before the submit event? The date should be converted to ISO format in order for it to be properly parsed server-side. This can be done via the toISOString method.

Another solution which would not require any JavaScript code is to handle that server-side by adding a partial method as described here. For example:

public partial class CategoriesController
{
    partial void OnCategoryUpdated(Category item)
    {
        item.Updated = DateTime.Now;
    }

    partial void OnCategoryCreated(Category item)
    {
        item.Updated = DateTime.Now;
    }
}