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

RaddatePicker compare with datetime.now

2 Answers 50 Views
Calendar
This is a migrated thread and some comments may be shown as answers.
Mohamed El-Sayed
Top achievements
Rank 1
Mohamed El-Sayed asked on 05 May 2014, 06:08 PM
Dears .

    kindly I need your support as I need to make if statement to compare between raddatepicker and datetime.now if raddatepicker for ex : 22/4/2014
and datetime.now give alert that it's in old date

2 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 1
answered on 06 May 2014, 04:46 AM
Hi Beka,

Please try the following C# code snippet to achieve your scenario.

C#:
protected void raddateCompareDate_SelectedDateChanged(object sender, Telerik.Web.UI.Calendar.SelectedDateChangedEventArgs e)
{
    DateTime selectedDate =Convert.ToDateTime(e.NewDate);
    if (selectedDate.Date != DateTime.Now.Date)//checking selected date and current date
    {
        if (selectedDate.Date < DateTime.Now.Date) //if selectedDate date is older than current date alert will show
            ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alertMessage", "alert('Old Date')", true);
    }
}

Let me know if you have any concern.
Thanks,
Shinu.
0
Mohamed El-Sayed
Top achievements
Rank 1
answered on 07 May 2014, 03:44 PM
Thanks Shinu , it's working well
Tags
Calendar
Asked by
Mohamed El-Sayed
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 1
Mohamed El-Sayed
Top achievements
Rank 1
Share this question
or