RadMonthYearPicker - Incorrect Server Side Old/New Dates

5 posts, 0 answers
  1. David
    David avatar
    1 posts
    Member since:
    Mar 2011

    Posted 01 Feb 2012 Link to this post

    Here is the behavior I am seeing with RadMonthYearPicker.

    In my ASPX I have:

    <telerik:RadMonthYearPicker ID="RadMonthYearPicker1" runat="server" Skin="WebBlue"  OnSelectedDateChanged="RadMonthYearPicker1_SelectedDateChanged" AutoPostBack="true" >
                </telerik:RadMonthYearPicker>


    In my code behind I have:

            protected void RadMonthYearPicker1_SelectedDateChanged(object sender, SelectedDateChangedEventArgs e)
            {
    }

    I old date is in the same year as new date, e.OldDate and e.NewDate are correct. If old date is in a different year as new date, new date is incorrect and is == to old date.



  2. Radoslav
    Admin
    Radoslav avatar
    1409 posts
    Member since:
    Sep 2012

    Posted 06 Feb 2012 Link to this post

    Hello David,

    I tried to reproduce the described issue but to no avail. On the following link I attached a small video which demonstrates how the described scenario works on my side. Additionally could you please try using the latest version of our controls and let me know if the issue still persist on your side.

    Looking forward for your reply.

    Regards,
    Radoslav
    the Telerik team

    Sharpen your .NET Ninja skills! Attend Q1 webinar week and get a chance to win a license! Book your seat now >>

  3. Ivan
    Ivan avatar
    2 posts
    Member since:
    Aug 2012

    Posted 19 Mar 2013 Link to this post

    I realize this thread is quite old, but I am running into the same scenario that David experienced and I am hoping someone can shed some light.

    Background:  We have a period setting (Month/Year combination) that can be updated by a user.  For example, if the setting was previously set to December, 2012 and it needs to be updated to January, 2013, the user should be able to view the existing period and update it.  I was thinking of using the RadMonthYearPicker.

    Problem:  The issue I am running into is that in order for the RadMonthYearPicker to display the current period setting, I first have to set its "SelectedDate" property to the current period setting.  I do this in the Page_Load event, but I have also tried it in the RadMonthYearPicker's Load event as well.  However, when I do that, the OldDate and the NewDate values are the same in the SelectedDateChanged event even though the NewDate should be different after being updated.

    If I do not set its "SelectedDate" property to the current period setting initially, the OldDate and the NewDate values differ and reflect the correct values in the SelectedDateChanged event.  The problem, of course, is that the current value is not being displayed initially and I need it to be displayed.

    <telerik:RadMonthYearPicker ID="rmyStartPeriod" runat="server" onselecteddatechanged="rmyStartPeriod_SelectedDateChanged">
    </telerik:RadMonthYearPicker>

    protected void Page_Load(object sender, EventArgs e)
    {
           if (!Page.IsPostBack)
           {
               rmyStartPeriod.SelectedDate = DateTime.Parse("12/01/2012");
           }
    }

    protected void rmyStartPeriod_SelectedDateChanged(object sender, Telerik.Web.UI.Calendar.SelectedDateChangedEventArgs e)
    {
           DateTime oldDate = e.OldDate.Value;
           DateTime newDate = e.NewDate.Value;
    }

    How can the RadMonthYearPicker control be set to a "initial/default" date without affecting the SelectedDateChanged functionality?

  4. Radoslav
    Admin
    Radoslav avatar
    1409 posts
    Member since:
    Sep 2012

    Posted 22 Mar 2013 Link to this post

    Hi Ivan,

    I tried to reproduce the described issue with you code snippet, but everything works as expected. When the SelectedDate is set into the PageLoad event the OldDate and NewDate into the SelectedDateChanged event are different. On the following link I attached a small video which demonstrates that. Also I am sending you a simple example based on you code. Please check it out and let me know what differs in your case.

    Looking forward for your reply.

    Regards,
    Radoslav
    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.

  5. Ivan
    Ivan avatar
    2 posts
    Member since:
    Aug 2012

    Posted 25 Mar 2013 Link to this post

    Hi Radoslav,

    I did not keep my original code since I was trying different things, but I just tried to recreate it and I could not get the problem to occur again.  I must have been doing something wrong in my code in the first place.  Thanks for your help.

Back to Top