Datepicker mindate and maxdate setting from code behind

9 posts, 0 answers
  1. Sanjay
    Sanjay avatar
    21 posts
    Member since:
    Nov 2010

    Posted 11 Jan 2011 Link to this post

    Hello,
    I have the following code in code behind page. The rdpDate is a date picker. The code does not seem to take effect as in the entry mode it allows to select earlier than the mindate and also the later than the maxdate?

     

     

    If Not currProject.ProjectStart = Nothing Then

     

    rdpDate.MinDate = currProject.ProjectStart

     

     

    End If

     

     

     

    If Not currProject.ProjectEnd = Nothing Then

     

    rdpDate.MaxDate = currProject.ProjectEnd

     

     

    End If


     

    Here is the aspx control defination:

    <

     

     

    telerik:RadDatePicker ID="rdpDate" runat="server" DateInput-CausesValidation="true"

     

     

     

    SkinID="dpRegular">

     

     

     

    </telerik:RadDatePicker>

     



    Thanks,
    Sanjay

  2. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 12 Jan 2011 Link to this post

    Hello Sanjay,


    I am not familiar with the issue that you are facing. In which event you are setting the MinDate and MaxDate properties? I tried in Page_Load and that worked well for me.

    Code:
    protected void Page_Load(object sender, EventArgs e)
    {
         rdpDate.MinDate = DateTime.Now.Date;         // Example
    }


    Also check whether you are getting correct values in Date format - currProject.ProjectStart and currProject.ProjectEnd.



    -Shinu
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Mike Dennis
    Mike Dennis avatar
    51 posts
    Member since:
    Mar 2006

    Posted 29 Jun 2011 Link to this post

    I have the same problem with the maxdate being set from the code behind.  I am setting it in the load event of the datepicker.  I am setting the DateInput.MaxDate and Calendar.RangeMaxDate to the same value.  The calendar gets restricted, but the input takes any value.  I don't get an errors or anything.. It just doesn't seem to update the validater for the input to the new max.  Is this an issue with the DatePicker or could I be missing something that would cause that?
  5. Maria Ilieva
    Admin
    Maria Ilieva avatar
    4017 posts

    Posted 04 Jul 2011 Link to this post

    Hello Mike,

    Find attached a small runnable application which uses your settings and works correctly on my side. Test it locally and let me know what the difference in your case is.


    Greetings,
    Maria Ilieva
    the Telerik team

    Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.

  6. Maria Ilieva
    Admin
    Maria Ilieva avatar
    4017 posts

    Posted 04 Jul 2011 Link to this post

    Hello Mike,

    Find attached a small runnable application which uses your settings and works correctly on my side. Test it locally and let me know what the difference in your case is.


    Greetings,
    Maria Ilieva
    the Telerik team

    Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.

  7. Mike Dennis
    Mike Dennis avatar
    51 posts
    Member since:
    Mar 2006

    Posted 05 Jul 2011 Link to this post

    Maria,

    I can reproduce my issue with your code if I have the MaxDate set (tested 1/1/2100) in the control code of the aspx page.  When the MaxDate is changed in the code behind, It updates the MaxDate for the calendar, but the textbox part still uses the old limit.

    Mike Dennis
  8. Maria Ilieva
    Admin
    Maria Ilieva avatar
    4017 posts

    Posted 08 Jul 2011 Link to this post

    Hi Mike,

    Note that it is not a correct scenario to set the Min or Max date properties in mark up and code behind at the same time. I would suggest you to use just one way for setting the properties so they would be correctly applied.


    Best wishes,
    Maria Ilieva
    the Telerik team

    Register for the Q2 2011 What's New Webinar Week. Mark your calendar for the week starting July 18th and book your seat for a walk through of all the exciting stuff we will ship with the new release!

  9. Mike Dennis
    Mike Dennis avatar
    51 posts
    Member since:
    Mar 2006

    Posted 08 Jul 2011 Link to this post

    Maria,

    I think there had been a reason why I needed to have it in both places, but I guess I will have to handle that all in the code behind then..  It seems like that would be considered a bug though, since it partially works (calendar, not input).

    Mike Dennis
  10. Maria Ilieva
    Admin
    Maria Ilieva avatar
    4017 posts

    Posted 13 Jul 2011 Link to this post

    Hi Mike,

    We will log this behaviour in our system and will proceed with some additional tests for the control in order to isolate if the problem is a bug and if possible fix is available.
    Thank you for bringing this to our attention.

    Kind regards,
    Maria Ilieva
    the Telerik team

    Register for the Q2 2011 What's New Webinar Week. Mark your calendar for the week starting July 18th and book your seat for a walk through of all the exciting stuff we will ship with the new release!

Back to Top
UI for ASP.NET Ajax is Ready for VS 2017