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

Rad Datepicker not updating the date text in input field

14 Answers 517 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Sandip Nandi
Top achievements
Rank 1
Sandip Nandi asked on 09 Feb 2012, 09:33 AM
Hi All
  I have a very strange issue, which occurs only in IE (all versions) and that too some times.
  I am using a Datepicker control, where we enter the date in the input field manually and then do a server post back, the issue  occurs randomly where the input date is not considered and it considers the previously entered date.
   
   We did a little client side debugging and found that this occurs when we enter the date manually and use a mouse to do a server postback, If we use the keyboard tab to do a server post back it this does not occurs.
   And even with mouse if we click any where in the page and then do a post back, this issue does not occurs.
  I guess this has to do with some internal telerik client side event, which is responsible for updating the datepicker, which does not fires at times.
 
   Surprisingly the error does not happens in Chrome, Firefox, Safari, Opera or any advanced browser.

/SANDIP

14 Answers, 1 is accepted

Sort by
0
Tsvetoslav
Telerik team
answered on 09 Feb 2012, 12:27 PM
Hello Sandip,

Could you paste your mark-up and code behind? Please, use the CODE FORMATTER tool of the ticket editor.

Regards,
Tsvetoslav
the Telerik team
Sharpen your .NET Ninja skills! Attend Q1 webinar week and get a chance to win a license! Book your seat now >>
0
Sandip Nandi
Top achievements
Rank 1
answered on 10 Feb 2012, 07:26 AM
The Code for our markup will be

&nbsp;&lt;tr id="trDateFilter" runat="server" class="DateFilterClass" style="display: none;<br>&nbsp; &nbsp; &nbsp; &nbsp; width: 100px;"&gt;<br>&nbsp; &nbsp; &nbsp; &nbsp; &lt;td align="left"&gt;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;asp:Literal ID="Literal11" runat="server" Text="&lt;%$R:lbl_DateFrom%&gt;" /&gt;<br>&nbsp; &nbsp; &nbsp; &nbsp; &lt;/td&gt;<br>&nbsp; &nbsp; &nbsp; &nbsp; &lt;td align="left"&gt;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;telerik:RadDatePicker ID="radMeetingFrom" runat="server" Width="150" CssClass="radMeetingFromClass"&gt;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;DateInput OnClientDateChanged="radMeetingFromOnClientDateChanged" &gt;&lt;/DateInput&gt;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;/telerik:RadDatePicker&gt;<br>&nbsp; &nbsp; &nbsp; &nbsp; &lt;/td&gt;<br>&nbsp; &nbsp; &nbsp; &nbsp; &lt;td align="left"&gt;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;asp:Literal ID="Literal4" runat="server" Text="&lt;%$R:lbl_ToDate%&gt;" /&gt;<br>&nbsp; &nbsp; &nbsp; &nbsp; &lt;/td&gt;<br>&nbsp; &nbsp; &nbsp; &nbsp; &lt;td align="left"&gt;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;telerik:RadDatePicker ID="radMeetingTo" runat="server" Width="150" CssClass="radMeetingToClass"&gt;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&lt;DateInput OnClientDateChanged="radMeetingToOnClientDateChanged" &gt;&lt;/DateInput&gt;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;/telerik:RadDatePicker&gt;<br>&nbsp; &nbsp; &nbsp; &nbsp; &lt;/td&gt;<br>&nbsp; &nbsp; &nbsp; &nbsp; &lt;td&gt;<br>&nbsp; &nbsp; &nbsp; &nbsp; &lt;/td&gt;<br>&nbsp; &nbsp; &lt;/tr&gt;



The Server side postback code 
&lt;asp:Button ID="btnSearch" Text="&lt;%$R:lbl_Search%&gt;" runat="server" OnClick="SearchClick"<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Width="70px" /&gt;


And on the server side we are doing usual procedures of picking the dates from two datepickers
we also had a client side validate method associated with the SearchClick, which checks the date range and returns true, so that it can postback.

ValidateDates = function () {
           // hiddenDateFilterClass will check if the user has selected the date option.

            if ($(".hiddenDateFilterClass").val() == "1") {
                var selectfromdate = $(".radMeetingFromClass input").val();
                var selectTodate = $(".radMeetingToClass input").val();
                if (selectfromdate == "" || selectTodate == "") {
                    alert("From and To dates are required");
                    return false;
                }
            }
        }



as I said this error is very random in nature and occurs only few times and only in the browser IE.

/SANDIP






0
Sandip Nandi
Top achievements
Rank 1
answered on 10 Feb 2012, 07:27 AM
The Code for our markup will be

&nbsp;&lt;tr id="trDateFilter" runat="server" class="DateFilterClass" style="display: none;<br>&nbsp; &nbsp; &nbsp; &nbsp; width: 100px;"&gt;<br>&nbsp; &nbsp; &nbsp; &nbsp; &lt;td align="left"&gt;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;asp:Literal ID="Literal11" runat="server" Text="&lt;%$R:lbl_DateFrom%&gt;" /&gt;<br>&nbsp; &nbsp; &nbsp; &nbsp; &lt;/td&gt;<br>&nbsp; &nbsp; &nbsp; &nbsp; &lt;td align="left"&gt;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;telerik:RadDatePicker ID="radMeetingFrom" runat="server" Width="150" CssClass="radMeetingFromClass"&gt;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;DateInput OnClientDateChanged="radMeetingFromOnClientDateChanged" &gt;&lt;/DateInput&gt;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;/telerik:RadDatePicker&gt;<br>&nbsp; &nbsp; &nbsp; &nbsp; &lt;/td&gt;<br>&nbsp; &nbsp; &nbsp; &nbsp; &lt;td align="left"&gt;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;asp:Literal ID="Literal4" runat="server" Text="&lt;%$R:lbl_ToDate%&gt;" /&gt;<br>&nbsp; &nbsp; &nbsp; &nbsp; &lt;/td&gt;<br>&nbsp; &nbsp; &nbsp; &nbsp; &lt;td align="left"&gt;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;telerik:RadDatePicker ID="radMeetingTo" runat="server" Width="150" CssClass="radMeetingToClass"&gt;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&lt;DateInput OnClientDateChanged="radMeetingToOnClientDateChanged" &gt;&lt;/DateInput&gt;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;/telerik:RadDatePicker&gt;<br>&nbsp; &nbsp; &nbsp; &nbsp; &lt;/td&gt;<br>&nbsp; &nbsp; &nbsp; &nbsp; &lt;td&gt;<br>&nbsp; &nbsp; &nbsp; &nbsp; &lt;/td&gt;<br>&nbsp; &nbsp; &lt;/tr&gt;



The Server side postback code 
&lt;asp:Button ID="btnSearch" Text="&lt;%$R:lbl_Search%&gt;" runat="server" OnClick="SearchClick"<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Width="70px" /&gt;


And on the server side we are doing usual procedures of picking the dates from two datepickers
we also had a client side validate method associated with the SearchClick, which checks the date range and returns true, so that it can postback.

ValidateDates = function () {
           // hiddenDateFilterClass will check if the user has selected the date option.

            if ($(".hiddenDateFilterClass").val() == "1") {
                var selectfromdate = $(".radMeetingFromClass input").val();
                var selectTodate = $(".radMeetingToClass input").val();
                if (selectfromdate == "" || selectTodate == "") {
                    alert("From and To dates are required");
                    return false;
                }
            }
        }



as I said this error is very random in nature and occurs only few times and only in the browser IE.

/SANDIP
 
0
PhonDev
Top achievements
Rank 1
answered on 10 Feb 2012, 08:01 AM

Trying to format the code :-)

 <tr id="trDateFilter" runat="server" class="DateFilterClass" style="display: none;<br> width: 100px;">
    <
br>        
        <
td align="left"><br>            
            <
asp:Literal ID="Literal11" runat="server" Text="<%$R:lbl_DateFrom%>" /><br>        
        </
td><br>        
        <
td align="left"><br>            
            <
telerik:RadDatePicker ID="radMeetingFrom" runat="server" Width="150" CssClass="radMeetingFromClass"><br>                
                <
DateInput OnClientDateChanged="radMeetingFromOnClientDateChanged" ></DateInput><br>                <br>            
            </
telerik:RadDatePicker><br>        
        </
td><br>        
        <
td align="left"><br>            
            <
asp:Literal ID="Literal4" runat="server" Text="<%$R:lbl_ToDate%>" /><br>        
        </
td><br>        
        <
td align="left"><br>            
            <
telerik:RadDatePicker ID="radMeetingTo" runat="server" Width="150" CssClass="radMeetingToClass"><br>  
                <
DateInput OnClientDateChanged="radMeetingToOnClientDateChanged" ></DateInput><br
           </
telerik:RadDatePicker><br>        
        </
td><br>        
        <
td><br>        
        </
td><br>   
</
tr>

The Server side postback code
 
<asp:Button ID="btnSearch" Text="<%$R:lbl_Search%>" runat="server" OnClick="SearchClick"<br>                                Width="70px" />



0
Tsvetoslav
Telerik team
answered on 10 Feb 2012, 01:07 PM
Thanks Kenneth,

Snadip, please, open-up a formal support ticket and attach your project files. The information provided does not give enough indication what the problem might be. Besides, you are talking about your implementation in future tense which is still more confusing.

Thanks for that.

Regards, Tsvetoslav
the Telerik team
Sharpen your .NET Ninja skills! Attend Q1 webinar week and get a chance to win a license! Book your seat now >>
0
Gregory
Top achievements
Rank 2
answered on 20 Aug 2014, 08:06 PM
Hi Tsvetoslav's

Were you able to find what was wrong for this issue?
I am having a similar problem. 2 radDatePickers are set to default dates when the page loads. After changing the dates, validating the form and going on to the next page, if I click the back button, the radDatePickers display the previous date changed. But if I submit the page this way, the default dates are actually passed in the code behind.
In addition, when I have clicked my back arrow to go to the previous page and the datepicker is displayed the wanted date, a click inside the date input will change the date to the default date.

Thank you
Gregory
0
Princy
Top achievements
Rank 2
answered on 21 Aug 2014, 06:14 AM
Hi Gregory,

Please try the below sample code snippet which works fine at my end.

ASPX:
<telerik:RadDatePicker ID="rdatepickerStartDate" runat="server" AutoPostBack="true">
</telerik:RadDatePicker>
<telerik:RadButton ID="rbtnNextPage" runat="server" Text="NextPage" OnClick="rbtnNextPage_Click">
</telerik:RadButton>

JavaScript:
function pageLoad() {
    var date = new Date();
    var datePicker = $find("<%=rdatepickerStartDate.ClientID%>");
    if (datePicker.get_textBox().value == "") {
        datePicker.set_selectedDate(date);
    }
}

C#:
protected void rbtnNextPage_Click(object sender, EventArgs e)
{
    string date = rdatepickerStartDate.SelectedDate.ToString();
    Response.Redirect("Default.aspx", false);
}

Thanks,
Princy.
0
Gregory
Top achievements
Rank 2
answered on 21 Aug 2014, 02:02 PM
Hello Princy,

Thank you for your answer.
I am sure sure how this is going to work according to my scenario. I think I have not been clear. When I said the back button I meant the web browser button. Therefore there is no control such as rbtnNextPage.

My issue is exactly the same as described on that post that I just found:
http://www.telerik.com/forums/raddatepicker-dateinput-displays-wrong-date-when-returning-to-previous-page-in-chrome?actionMode=replyPost&postId=35e6e342-d7b2-4295-a241-e507d5f7784f

I am going to investigate further through that post since I think it is more my case than the issue described here.

Thank you.
Gregory
0
Princy
Top achievements
Rank 2
answered on 22 Aug 2014, 05:04 AM
Hi Gregory,

I have checked the link mentioned in the above post and the solution provided in that post is working fine at my end. I have tried with 2013 Q1 version and 2014 Q2 version. Please have a look into the sample project which works fine at my end.

Thanks,
Princy.
0
Gregory
Top achievements
Rank 2
answered on 22 Aug 2014, 04:11 PM
Princy,

Thank you for the sample project. This will help to show my issue which occurs in your project.
Simply change
Response.Redirect("Default.aspx", false);
for
Response.Redirect("Default.aspx?" + RadDatePicker1.SelectedDate.Value.ToShortDateString(), false);

In this context, I change the date to yesterday and click next page. I hit the back button of the web browser. Now the date input displays yesterday's date, but if I hit the next page button again, the Url shows default.aspx?8/22/2014.

Please let me know if what I did is right and if you can reproduce this.

Thank you
Gregory
0
Gregory
Top achievements
Rank 2
answered on 22 Aug 2014, 04:37 PM
Princy,

Please also add this code in DatePickerDefaultDate.aspx.cs to make more sense:
protected void Page_Load(object sender, EventArgs e)
    {
        if(!this.IsPostBack)
            this.RadDatePicker1.SelectedDate = DateTime.Now;
    }

Thank you :)
0
Angel Petrov
Telerik team
answered on 27 Aug 2014, 07:52 AM
Hello Gregory,

Indeed after applying the code provided in your last two posts I was able to observed the described behavior. It seems that the value is persisted only initially but not on subsequent redirects. I have already logged this issue into our system(please visit this link) and our developers will have the care to investigate it and integrate the necessary changes in the controls.

As a token of gratitude for reporting this problem to us I have updated your Telerik points.

Regards,
Angel Petrov
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:17 PM
Hello Angel,

Thank you for the confirmation and the points. Will it be said on that page when the fix is made to the control? Can I track it from my telerik account like I track forum posts?

Thank you again
Gregory
0
Angel Petrov
Telerik team
answered on 01 Sep 2014, 07:10 AM
Hi Gregory,

We will update the status of the feedback item once our developers start working on it and once more when it is resolved. However I can not provide a certain time-frame in which the fix will be included. Considering the aforementioned I recommend monitoring the feedback item status.

Regards,
Angel Petrov
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
General Discussions
Asked by
Sandip Nandi
Top achievements
Rank 1
Answers by
Tsvetoslav
Telerik team
Sandip Nandi
Top achievements
Rank 1
PhonDev
Top achievements
Rank 1
Gregory
Top achievements
Rank 2
Princy
Top achievements
Rank 2
Angel Petrov
Telerik team
Share this question
or