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

Keep selected date

3 Answers 80 Views
Calendar
This is a migrated thread and some comments may be shown as answers.
Web Services
Top achievements
Rank 2
Web Services asked on 18 Dec 2012, 10:32 PM
I have a calendar where I only allow the user to select one day. Here's the code I have for that.

Dim selDate
        If (e.SelectedDates.Count <> 0) Then
            selDate = e.SelectedDates(e.SelectedDates.Count - 1).Date
            calDay.SelectedDate = selDate
            litDaySpec.Text = clsData.displayReservationsForADay(calDay.SelectedDate)
            Dim dateDate As New DateTime(calDay.SelectedDate.Year, calDay.SelectedDate.Month, calDay.SelectedDate.Day, 12, 0, 0)
            If getDST(calDay.SelectedDate) Then
                'If (TimeZone.CurrentTimeZone.IsDaylightSavingTime(dateDate)) Then
                lblTime.Text = "6:00"
            Else
                lblTime.Text = "5:00"
            End If
        Else

The only problem with this is, if they have a date selected, and click that same date. I.e. 12/18/2012 is selected and they click 12/18/2012 again, it deselects that date so not date is selected. Is there a way I can make it keep that 12/18 selected if they click it and it's already been selected?





3 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 19 Dec 2012, 08:28 AM
Hi,

Try setting EnableMultiSelect property of RadCalendar to false to allow the user to select one day.  You can cancel the OnDateSelecting event to achieve your scenario as follows.

ASPX:
<telerik:RadCalendar ID="cal" runat="server" EnableMultiSelect="false" ClientEvents-OnDateSelecting="OnDateSelecting">
</telerik:RadCalendar>

JS:
<script type="text/javascript">
    function OnDateSelecting(sender, args) {
        if (args.get_isSelecting() == false) {
            args.set_cancel(true);
        }
    }
</script>

Hope this helps.

Regards,
Princy.

0
Web Services
Top achievements
Rank 2
answered on 19 Dec 2012, 04:59 PM
I have enable multiselect set to false.
<telerik:RadCalendar ShowRowHeaders="false" ID="dateInput" runat="server" EnableMultiSelect="false" AutoPostBack="true"></telerik:RadCalendar>

I put in your JS, but it still deselects the day if you click on the currently selected day






0
Kevin
Top achievements
Rank 2
answered on 19 Dec 2012, 07:34 PM
Hello Web Services,

From what you posted, it doesn't look like your handling the client-side OnDateSelecting client-side event. You need to add the property, ClientEvents-OnDateSelecting="OnDateSelecting", as noted in the previous post by Princy.

I hope that helps.
Tags
Calendar
Asked by
Web Services
Top achievements
Rank 2
Answers by
Princy
Top achievements
Rank 2
Web Services
Top achievements
Rank 2
Kevin
Top achievements
Rank 2
Share this question
or