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

Datepicker mindate and maxdate setting from code behind

8 Answers 789 Views
Calendar
This is a migrated thread and some comments may be shown as answers.
Sanjay
Top achievements
Rank 1
Sanjay asked on 11 Jan 2011, 10:46 PM
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

8 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 12 Jan 2011, 07:36 AM
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
0
Mike Dennis
Top achievements
Rank 1
answered on 29 Jun 2011, 06:31 PM
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?
0
Maria Ilieva
Telerik team
answered on 04 Jul 2011, 03:46 PM
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.

0
Maria Ilieva
Telerik team
answered on 04 Jul 2011, 03:46 PM
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.

0
Mike Dennis
Top achievements
Rank 1
answered on 05 Jul 2011, 04:01 PM
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
0
Maria Ilieva
Telerik team
answered on 08 Jul 2011, 10:08 AM
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!

0
Mike Dennis
Top achievements
Rank 1
answered on 08 Jul 2011, 06:05 PM
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
0
Maria Ilieva
Telerik team
answered on 13 Jul 2011, 11:49 AM
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!

Tags
Calendar
Asked by
Sanjay
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Mike Dennis
Top achievements
Rank 1
Maria Ilieva
Telerik team
Share this question
or