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

Error icon in date selection (with minDate set)

4 Answers 110 Views
Calendar
This is a migrated thread and some comments may be shown as answers.
Joe
Top achievements
Rank 2
Joe asked on 12 Mar 2009, 08:21 PM
I'm using two Calendar date/time pickers to set a date range that is used for a SQL DB lookup. I only want the user to be able to select a date that is no more then 30 days from the current date/time in both date pickers. The max date is always today's date/time.

I can get the calendar to only allow 30 days from today but it produces an error  if I choose the last available date (today - 1 month).

The code that I am using is as follows:

Protected Sub RadDateTimePicker1_Load(ByVal sender As ObjectByVal e As System.EventArgs) Handles RadDateTimePicker1.Load  
        Dim dt As New DateTime()  
        dt = RadDateTimePicker1.MinDate  
        dt = Date.Now.AddMonths(-1)  
        RadDateTimePicker1.MinDate = dt  
        RadDateTimePicker1.MaxDate = Date.Now  
    End Sub 
 
    Protected Sub RadDateTimePicker2_Load(ByVal sender As ObjectByVal e As System.EventArgs) Handles RadDateTimePicker1.Load  
        Dim dt As New DateTime()  
        dt = RadDateTimePicker2.MinDate  
        dt = Date.Now.AddMonths(-1)  
        RadDateTimePicker2.MinDate = dt  
        RadDateTimePicker2.MaxDate = Date.Now  
    End Sub 

 

Any suggestions on how to prevent the error icon (triangle) and only allow 30 days from the current date/time?

 

Thanks,

Joe

4 Answers, 1 is accepted

Sort by
0
Pavlina
Telerik team
answered on 16 Mar 2009, 05:23 PM
Hi Joe,

I am sending you a small runnable application which demonstrates described behavior.
Please give it a try and see if it works for you.

Regards,
Pavlina
the Telerik team


Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
Joe
Top achievements
Rank 2
answered on 17 Mar 2009, 05:20 PM
Thanks for the code example. I loaded (and ran it).

It contained two date pickers. I am guessing to demostrate different methods?

The code in your fist example:
DateTime dt = new DateTime();  
dt = RadDateTimePicker1.MinDate;  
dt = System.DateTime.Now.AddMonths(-1);  
RadDateTimePicker1.MaxDate = System.DateTime.Now; 
Doesn't appear to restrict the user from selecting any date.

The second date picker code:
DateTime dt = new DateTime();  
dt = RadDateTimePicker2.MinDate;  
dt = (new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day + 1, 0, 0, 0)).AddDays(-30);  
RadDateTimePicker2.MinDate = dt;  
RadDateTimePicker2.MaxDate = System.DateTime.Now; 
Does restrict the user to 30 days from today's date.

Was that what you were trying to demostrate?

Also, when I added the code in line 3, I am restricted to choosing a date 30 days from today but I still get the error (triangle icon in place of the date).

Thanks,
Joe

 

 

 

0
Accepted
Pavlina
Telerik team
answered on 20 Mar 2009, 01:03 PM
Hi Joe,

I am sending you a modified project, which handles the desired functionality.
Also note that two DatePickers restrict the user from selecting any date.
Give it a try and see how it goes or if I am leaving something out.

I hope this helps.

All the best,
Pavlina
the Telerik team


Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
Joe
Top achievements
Rank 2
answered on 20 Mar 2009, 08:55 PM
Tat appears to have done the trick. I'll compare the two code samples you supplied to figure out the difference!

Thanks!
Joe
Tags
Calendar
Asked by
Joe
Top achievements
Rank 2
Answers by
Pavlina
Telerik team
Joe
Top achievements
Rank 2
Share this question
or