This is a migrated thread and some comments may be shown as answers.

RadDatePicker DateInput displays wrong date when returning to previous page in Chrome

10 Answers 99 Views
Calendar
This is a migrated thread and some comments may be shown as answers.
Hans Gunnar
Top achievements
Rank 1
Hans Gunnar asked on 24 Apr 2013, 12:24 PM
Hi,

There seems to be a bug with the displayed date vs selected date when you use the back-button to return to a page where you have done a date selection.

I've only seen this with Chrome v26 and Firefox v20, not Firefox v19 or IE 10.

How to recreate:
Go to: http://demos.telerik.com/aspnet-ajax/calendar/examples/design/sunny/defaultcs.aspx
All date boxes there have todays date pre-selected and displayed in the dateinput field.
Select another date for one of the date pickers.
Go to another web page in the left hand menu (i.e. "DatePicker - First Look").
Then click the back-button in the browser.
Notice now that the date you changed to in the step above is displayed as you left it. But when opening the calendar you notice that today's date is actually the selected one.

On a page where you have a post back the user may go back and they see their date is selected, but when they submit the form the default (today's) date is the one actually used.

In IE 10 and Firefox 19 the date you changed to is the one displayed and selected when you try the same thing.

Not sure if this is a bug in the RadDatePicker control, or a bug in Chrome and Firefox, but would be nice if you can have a look at it.

10 Answers, 1 is accepted

Sort by
0
Vasil
Telerik team
answered on 25 Apr 2013, 08:58 AM
Hello Hans,

Indeed, there was a problem with the auto-fill from browsers on back button inside the RadInputControl that we have fixed for the latest service pack. However, the get_selectedDate does not read the auto-completed value by default, it is updated only on focus, since we didn't want to introduce big breaking changes that will affect lots of users.

To workaround this problem in the picker, you can use this JS to override the get_selectedDate of the DateInput. Place the code under your ScriptManager, or above the first picker declared in your page.
<script type="text/javascript">
    Telerik.Web.UI.RadDateInput.prototype.get_selectedDate = function ()
    {
        if (!this._calledAtleastOnce)
        {
            //update value when it is filled by browser's autofill on back button.
            this._calledAtleastOnce = true;
            if (this._lastSetTextBoxValue !== this._textBoxElement.value)
            {
                this._updateHiddenValue();
            }
        }
        return this._value ? new Date(this._value) : null;
    }
</script>

Regards,
Vasil
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
0
Hans Gunnar
Top achievements
Rank 1
answered on 25 Apr 2013, 09:59 AM
Thank you. Adding this script seems to work well.
0
Andrew
Top achievements
Rank 1
Veteran
answered on 19 Jul 2013, 03:51 PM
I am also getting this issue chrome, the fix did not work for me. and ie10 throws a javascript error.

I am also running the latest version of the controls
0
Vasil
Telerik team
answered on 24 Jul 2013, 08:39 AM
Hello Andrew,

What is the error that you get? Do you have any custom scripts in the page?
Sharing us more information will help us to determinate what exact issue you are facing, so if possible please send us runnable code that we can test.

Regards,
Vasil
Telerik
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to the blog feed now.
0
Gregory
Top achievements
Rank 2
answered on 21 Aug 2014, 02:04 PM
Hello Vasil,

I am having the same issue as described on this post. I tried to add the script but it did not change anything in Chrome and Firefox.
This behavior applies also to IE8 for what I can test. None of these browsers can pick up the js error
Nevertheless, in IE11, hitting the back button will display the date picker with the default date. Even using any emulation mode in IE11. This without adding the script.
Also the script added in IE11 will return an error "Unable to get property prototype of undefined or null reference (see attached file)

Do you have any new info about this?

Thank you
Gregory
0
Vasil
Telerik team
answered on 22 Aug 2014, 10:41 AM
Hi Gregory,

The error that you get happens when you add the script on page where there is no RadDateInput, or if you place it above the ScriptManager. In this case your script executes before the scripts of the DateInput are included. If you want to override particular method, the method should be first defined. So move your script below the ScriptManager, and make sure it is on page where there is DateInput/DatePicker.

Regards,
Vasil
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
0
Gregory
Top achievements
Rank 2
answered on 22 Aug 2014, 04:27 PM
Vasil,

Yes you were right. This script at the end of my page did not raise an error. Nevertheless, my date input for my calendar is still displaying the previous date meanwhile submitting the form will take the default date of the radCalendar.
I made a quick video here : https://www.dropbox.com/s/6yjrssdbnbhh7my/date%20picker%20not%20updating.avi
I change the date and submit. Date is ok. Hit the back button, it displays my changed date. Submit again. This time the date is the default date, not mine.

Thank you
Gregory
0
Maria Ilieva
Telerik team
answered on 27 Aug 2014, 10:55 AM
Hello Gregory,

I further tested the provided approach on my end but was not able to replicate the issue you demonstrates in the test movie.
Find attached a sample runnable example that works properly on my side.
Test it locally and verify what the difference in your case is.

Regards,
Maria Ilieva
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
0
Gregory
Top achievements
Rank 2
answered on 27 Aug 2014, 01:26 PM
Hello Maria,

Thank you for investigating. I have been speaking about this issue on another post too.
http://www.telerik.com/forums/rad-datepicker-not-updating-the-date-text-in-input-field#XVzF0fTm5UyWanPSavvGKA

In this post your team has been able to reproduce my issue and the problem has been logged to be taken care of by your developers.

Thank you
Gregory
0
Eyup
Telerik team
answered on 01 Sep 2014, 08:11 AM
Hello Gregory,

I'm glad you've came up with a mutual result.
I would suggest that you address any further questions in the mentioned thread.

Regards,
Eyup
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
Tags
Calendar
Asked by
Hans Gunnar
Top achievements
Rank 1
Answers by
Vasil
Telerik team
Hans Gunnar
Top achievements
Rank 1
Andrew
Top achievements
Rank 1
Veteran
Gregory
Top achievements
Rank 2
Maria Ilieva
Telerik team
Eyup
Telerik team
Share this question
or