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

How do I get the clicked date server side when EnableMultiSelect=true?

3 Answers 67 Views
Calendar
This is a migrated thread and some comments may be shown as answers.
Vithiya
Top achievements
Rank 1
Vithiya asked on 23 Feb 2010, 03:52 PM
I have a calendar that has EnableMultiSelect=true. The user is now able to select one or multiple dates on the calendar. On the server side I need to know the date that user clicks if he is selecting one at a time. Currently the selected date property seems to be good only for single selection mode. The selecteddates property for the multiselectionmode has all the selected dates which does not help me. I need to know the date the user clicked on when the calendar is in multiselection mode. The focused date does not seem to hold the correct value either.

Thanks,
Vithiya

3 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 24 Feb 2010, 05:37 AM
Hello Vithiya,

You can retrieve the last selected/clicked date from the SelectedDates collection in SelectionChanged event.

C#:
 
    protected void RadCalendar1_SelectionChanged(object sender, Telerik.Web.UI.Calendar.SelectedDatesEventArgs e) 
    { 
        if (e.SelectedDates.Count != 0) 
        { 
            Response.Write(e.SelectedDates[e.SelectedDates.Count - 1].Date.ToString()); // Last selected date 
        } 
    } 

-Shinu.
0
Michael
Top achievements
Rank 1
answered on 06 Apr 2011, 07:56 AM
Hi

I don't want to get the last date in the calendar, I want to get the actual date that is clicked. Say I clicked on the 1st, and then I clicked on the 30th, and then I clicked on the 15th, I won't the last postback click to show me the 15th not the 30th. Is this possible?
0
Shinu
Top achievements
Rank 2
answered on 06 Apr 2011, 08:19 AM
Hello Michael,

You can achieve this by subscribing the client event OnDateClick and try the following code there.
javascript:
function OnDateClick(sender, eventArgs)
  {
     var day = eventArgs.get_renderDay();
     var formatInfo = sender.DateTimeFormatInfo;
     var formattedDate = formatInfo.FormatDate(day.get_date(), formatInfo.ShortDatePattern);
     alert(formattedDate);
 }

Thanks,
Shinu.
Tags
Calendar
Asked by
Vithiya
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Michael
Top achievements
Rank 1
Share this question
or