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

RadDatePicker Calendar Month/Year Changed Server-Side Event

1 Answer 152 Views
Calendar
This is a migrated thread and some comments may be shown as answers.
Jonathan
Top achievements
Rank 1
Jonathan asked on 27 Feb 2014, 03:45 AM
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!

1 Answer, 1 is accepted

Sort by
0
Eyup
Telerik team
answered on 03 Mar 2014, 06:57 AM
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.
Tags
Calendar
Asked by
Jonathan
Top achievements
Rank 1
Answers by
Eyup
Telerik team
Share this question
or