We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy.
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

DateTimePicker lose date value after postback

Thread ID:

Created:

Updated:

Platform:

Replies:

117665 Nov 25,2014 02:16 PM UTC Dec 2,2014 04:21 AM UTC ASP.NET MVC 5
loading
Tags: DateTimePicker
Roman Suska
Asked On November 25, 2014 02:16 PM UTC

Hello,
I have following problem: on a View I have a form with two DateTimePickers to select a time span and some other controls. If I submit the form and there are validation errors, the controller returns to this view, but the DateTimePickers are blank, they don't save the selected date's. Is there any possibility to prevent the DateTimePickers from loosing their date's after postback? Or at least can I somehow manually set the date's in the DateTimePickers?
Greetings
Roman Suska 

Sasikala Nagarajan [Syncfusion]
Replied On November 26, 2014 01:13 PM UTC

Hi Roman Suska,

Thanks for using Syncfusion products,

 

We have analyzed your query. We will let you know that we can achieve your requirement using our existing property “enablePersistance” (which is used to Enables or disables the state maintenance of DateTimePicker) in DateTimePicker control. By setting this value to “true” we can maintain the DateTimePicker value even after the post back the form.

 

Please find the below code snippet,

 

[_cshtml]

@Html.EJ().DateTimePicker("SampleDateTime_1").EnablePersistence(true)

                            @Html.EJ().DateTimePicker("SampleDateTime_2").EnablePersistence(true)

 

For your convenience we have prepared the sample based on this. Please find the sample from below location

Sample

 

Please let us know if you have further queries.

 

Regards,

Sasikala Nagarajan


Roman Suska
Replied On November 26, 2014 02:20 PM UTC

Hi Sasikala Nagarajan,
ok I got it, but I have another question. I have a dropdown list with places, that are available on the selected time span. This dropdown is populated with Ajax. After postback or when the page loads I run the script with $(window).load to populate the dropdown list. The problem is with this line:
var startDateTimeObj = $("#dataRozpoczecia").data("ejDateTimePicker"); 

The jQuery code returns "undefined", so I think the control isn't created yet. How can I get the value set on the DateTimePicker after postback or page loading?

Greetings,

Roman Suska


Manikandan Mariappan [Syncfusion]
Replied On November 27, 2014 01:06 PM UTC

Hi Roman Suska,

Sorry for the inconvenience.

We are unable to reproduce the reported issue. We have prepared the sample based on your requirement “To create object in $(window).load time” for the DateTimePicker control and the sample can be downloaded from the following location.

Sample Location : Sample

In this sample we can get the instance of the “DateTimepicker” and it is showcased with message.

Please check with the given sample. If still you face the problem, please revert us by modifying the sample based on your application along with replication procedure. This would be helpful for us to serve you or please share any screen shot of errors.

Please let us know if you have any concerns

Regards,

M.Manikandan


Roman Suska
Replied On November 28, 2014 09:49 AM UTC

Hi,
it seems to work now, I don't know what I did wrong last time. Thanks for helping me.
Greetings,
Roman Suska

Sasikala Nagarajan [Syncfusion]
Replied On December 2, 2014 04:21 AM UTC

Hi Roman,

Thanks for the update,

Please let us know if you have any further assistance.

Regards,

Sasikala Nagarajan



CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

;