RadDatePicker:Client side :setting up MaxDate and SeDate after clearing the special Days

2 posts, 0 answers
  1. Krishna
    Krishna avatar
    89 posts
    Member since:
    Jul 2008

    Posted 06 Oct 2009 Link to this post

    Hi,
    I have below requirement
    on page load I have set the Maxdate of the datepicker to today.. and I have some special days which are added when page load itself.
    that was fine..
    when i click on one button i need to do some changes to date picker at client side..
    The main inportant thing is the Selected date must be today + 10 days ..which i am unable to with below code
            var datpick1 = <%= datpick1.ClientID %>;  
            var datpick2 = <%= datpick2.ClientID %>;  
            var calendar2 = <%= datpick2.ClientID %>.GetCalendar();  
            calendar2.SpecialDays.Clear();  
            calendar2.SetMaxDate(datpick1.GetMaxDate());//datpick1.GetMaxDate() is 10 days greater than datpick2 max date  
            var da = new Date(datpick1.GetMaxDate());  
            da.setDate(da.getDate());  
            calendar2.SetDate(da); 

    1. Clear the special Days (working fine)
    2.Set the MaxDate() which also seems to be working fine
    3.Set the date using SetDate() which seems to be not working (with the max date greater than the max date defined on page load)
    if i give SetDate as less than or equal to the Pageload the Maxdate it is working fine.

    Please help me to set the date at client side ..
    Please let me know if i am missing any thingelse

    Thanks
    -Krishna
  2. Veli
    Admin
    Veli avatar
    2002 posts

    Posted 09 Oct 2009 Link to this post

    Hello Krishna,

    First of all, you are referring to the classic RadControls for ASP.NET, while the thread info says you are using RadCalendar for ASP.NET AJAX. I am assuming we are talking about the classic controls.

    The javascript you have provided contains some problematic statements, particularly:

    1. SetMaxDate()  is a property of the client RadDatePicker object. The respective property for RadCalendar is SetRangeMaxDate()

    2. Client RadCalendar object does not have a property names SetDate(). Such a property is provided by RadDatePicker.

    I believe you wanted to modify the max date and selected date of RadDatePicker. Now, with RadDatePicker, you are also using a RadDateInput (the textbox that displays the selected date). RadDateInput's client object also has its own MinDate and MaxDate property. When setting the MaxDate property of the picker, the new date is not updated as the MaxDate property of the date input. You need to manually set it:

    var picker = window['<%= datpick1.ClientID %>'];
    picker.SetMaxDate(new Date("10/20/2009"));
    picker.DateInput.MaxDate = picker.GetMaxDate();
    picker.SetDate(new Date("10/15/2009"));

    The above code works as expected now. Check it out.

    Regards,
    Veli
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Back to Top