This is a migrated thread and some comments may be shown as answers.
RadCalendar Validation
1 Answer 42 Views
This is a migrated thread and some comments may be shown as answers.
adam
Top achievements
Rank 1
adam asked on 04 May 2012, 01:57 PM
I can't find any examples or documentation on using asp.net validators with the RadCalendar (not the RadDatePicker).

Ideally, I'd like to have two calendars, and use the CompareValidator to ensure that one date is less than the other. Has anyone been able to do this?

1 Answer, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 1
answered on 07 May 2012, 08:07 AM
Hello Adam,

Since RadCalendar is not an input control, you cannot validate it directly. One approach is to access the selected date and check for the condition. Here is the sample code.
C#:
protected void Button1_Click(object sender, EventArgs e)
{
  DateTime d1 = RadCalendar1.SelectedDate;
  DateTime d2 = RadCalendar2.SelectedDate;
  if(d1<d2)
  {
    Response.Write("<script language=JavaScript>confirm('Please select a higher date');</script>");
  }
}

Thanks,
Princy.
Asked by
adam
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 1
Share this question
or