Keep selected date

4 posts, 0 answers
  1. Web Services
    Web Services avatar
    243 posts
    Member since:
    Apr 2008

    Posted 18 Dec 2012 Link to this post

    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?





  2. Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 19 Dec 2012 Link to this post

    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.

  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Web Services
    Web Services avatar
    243 posts
    Member since:
    Apr 2008

    Posted 19 Dec 2012 Link to this post

    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






  5. Kevin
    Kevin avatar
    360 posts
    Member since:
    Jul 2012

    Posted 19 Dec 2012 Link to this post

    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.
Back to Top