I am trying to set the current time to a DateTimePicker (with Format Time) like
this.myDateTimePicker.Value = DateTime.Now;
but when executing my code I am getting an exception
Object reference not set to an instance of an object
What I am doing wrong?
Thanks.
It Seems simple. $('#startdatetime-from'). datetimepicker({ language: 'en', format: 'yyyy-MM-dd hh:mm' });
On the All tab of the Property Sheet, make sure the Show Date Picker property is set to For dates. On the Data tab of the property sheet, type =Date() in the Default Value property for the field. Note: If you want to include the current time as well as the date, use the Now() function instead of Date().
Setting the Default Value To set the initial value that is rendered by the TimePicker, set the defaultValue property. This approach allows the component to display a value upon its initial render while remaining in an uncontrolled state.
The DateTimePicker control is used to allow the user to select a date and time, and to display that date and time in the specified format. The DateTimePicker control makes it easy to work with dates and times because it handles a lot of the data validation automatically.
You need to put that code after the InitializeComponent()
call is made. There is no instance of myDateTimePicker
until that point.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With