RadDatePicker Calendar Month/Year Changed Server-Side Event

2 posts, 0 answers
  1. Jonathan
    Jonathan avatar
    1 posts
    Member since:
    May 2012

    Posted 26 Feb 2014 Link to this post

    Hi all,

    I am currently using the OnDayRender event of the Calendar of my RadDatePicker which executes normally but, on a number of times only. My objective is to disable dates which are already taken and enable only Sundays for selection. So here's my code:

    protected void Calendar_OnDayRender(object sender, Telerik.Web.UI.Calendar.DayRenderEventArgs e)
    {
        // disable all days except Sunday
        if (e.Day.Date.DayOfWeek != DayOfWeek.Sunday)
        {
            CalendarDatesDisabler(sender, e);
        }
        // for Sundays, disable the dates already taken in the records
        // if no records with this date do not disable
        else // if (e.Day.Date.DayOfWeek == DayOfWeek.Sunday)
        {
            if (_dtForCalendarDayRender.Rows.Count > 0)
            {
                if (_dtForCalendarDayRender.Select(string.Format("startdate = '{0:MM/dd/yyyy}'", e.Day.Date)).Length == 0)
                    return;
     
                CalendarDatesDisabler(sender, e);
            }
        }
    }

    The above block of code runs just what it is expected to do, but it seems to trigger only for 30 number of days, maybe, after that it stops executing and then leaving other Sundays as enabled where it should not be. What can you suggest with this? I have searched the web with the server-side event of on month/year changed so that each time the month or year is selected it will disable the specific calendar days but found nothing.

    Thanks for your response!
  2. Eyup
    Admin
    Eyup avatar
    3009 posts

    Posted 03 Mar 2014 Link to this post

    Hi Jonathan,

    You can enable the AutoPostBack property of the calendar and ajaxify it:
    http://www.telerik.com/help/aspnet-ajax/ajax-ajaxmanager.html
    http://www.telerik.com/help/aspnet-ajax/ajax-ajaxpanel.html

    Alternatively, you can add a custom client-side logic on javascript.

    Hope this helps.

    Regards,
    Eyup
    Telerik
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the UI for ASP.NET AJAX, subscribe to the blog feed now.
  3. UI for ASP.NET Ajax is Ready for VS 2017
Back to Top