Disable dates in RadDatePicker

6 posts, 0 answers
  1. Saqib
    Saqib avatar
    24 posts
    Member since:
    Jan 2014

    Posted 21 Mar 2014 Link to this post

    How to disable days in RadDatePicker?
    If I google to find, everyone is referring to article which doesn't work in vs2013.
    http://www.telerik.com/support/code-library/disabling-calendar-days

    I also tried to do with following functions but it only disables like 10 total weekends.  It doesn't disable any previous months weekends. Any suggestions!
        Protected Sub Calendar_OnDayRender(ByVal sender As Object, ByVal e As Telerik.Web.UI.Calendar.DayRenderEventArgs)
            If (e.Day.Date.DayOfWeek = DayOfWeek.Saturday Or e.Day.Date.DayOfWeek = DayOfWeek.Sunday) Then     
                ' disable the selection for the specific day
                Dim calendarDay As RadCalendarDay = New RadCalendarDay
                calendarDay.Date = e.Day.Date
                calendarDay.IsSelectable = False
                calendarDay.IsDisabled = True
                'calendarDay.ItemStyle.CssClass = otherMonthCssClass
                calendarDay.ItemStyle.BackColor = Color.CadetBlue
                RadDatePicker1.Calendar.SpecialDays.Add(calendarDay)
            End If    End Sub
  2. Viktor Tachev
    Admin
    Viktor Tachev avatar
    1488 posts

    Posted 26 Mar 2014 Link to this post

    Hello Saqib,

    If you would like to disable days in RadDatePicker I would recommend checking this code library. It illustrates how to achieve such scenario. Note that you need to handle both client-side OnDayRender and server-side DayRender events.

    Try using the approach demonstrated in the code library and you should be able to achieve the functionality you are looking for.

    Regards,
    Viktor Tachev
    Telerik
     

    Build cross-platform mobile apps using Visual Studio and .NET. Register for the online webinar on 03/27/2014, 11:00AM US ET.. Seats are limited.

     
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Saqib
    Saqib avatar
    24 posts
    Member since:
    Jan 2014

    Posted 31 Mar 2014 in reply to Viktor Tachev Link to this post

    I tried to work with code library but when I try to run the project, I get "Object Null reference error".
    Somehow this control is not working right in VS 2013.
  5. Viktor Tachev
    Admin
    Viktor Tachev avatar
    1488 posts

    Posted 01 Apr 2014 Link to this post

    Hello Saqib,

    I tested the code-library and it seems to work as expected with Visual Studio 2013. Would you elaborate more on your setup and how to reproduce the error? Is the error replicated in all browsers?

    In case you would need only the weekends to be disabled you could use the EnableWeekends property to achieve the functionality with no additional code.

    <telerik:RadDatePicker ID="RadDatePicker1" runat="server" >
        <Calendar EnableWeekends="false">
        </Calendar>
    </telerik:RadDatePicker>

    Another approach you could use is to add the dates that should be disabled as SpecialDays. For example the following code will disable all Tuesdays.

    <telerik:RadDatePicker ID="RadDatePicker1" runat="server">
        <Calendar runat="server" ID="Calendar1">
            <SpecialDays>
                <telerik:RadCalendarDay Date="2014.04.01" Repeatable="Week" IsSelectable="false" IsDisabled="true"></telerik:RadCalendarDay>
            </SpecialDays>
        </Calendar>
    </telerik:RadDatePicker>


    Regards,
    Viktor Tachev
    Telerik
     

    Build cross-platform mobile apps using Visual Studio and .NET. Register for the online webinar on 03/27/2014, 11:00AM US ET.. Seats are limited.

     
  6. Saqib
    Saqib avatar
    24 posts
    Member since:
    Jan 2014

    Posted 01 Apr 2014 in reply to Viktor Tachev Link to this post

    In my existing Telerik project VS2013, I added DLL/css/js files from this project. I then register the control in the aspx page and declared the control in the page. Now when I try to run the page, it fails in the page_load function at the end of it.
    But if I comment this control, then the page loads successfully.
    Also there are 2 links: Classic and Ajax.
    I tried it with ajax.

    Also the control doesn't have the appearance (when I ran the downloaded code in VS2008) as the normal RadCalendar control out of box in toolkit.
  7. Viktor Tachev
    Admin
    Viktor Tachev avatar
    1488 posts

    Posted 04 Apr 2014 Link to this post

    Hi Saqib,

    Thank you for writing back.

    I have prepared a runnable website project from the code library. Try opening it in Visual Studio as a WebSite and try out the page.

    Regarding the appearance of the picker control. Please ensure that all Telerik assembly files that are added to your project have the same version. If the Telerik.Web.UI.dll and Telerik.Web.UI.Skins.dll are different versions the Skin for the RadDatePicker could be displayed in an unexpected way.

    Would you also let me know if the other suggestions (using EnableWeekends property of SpecialDays) for achieving the functionality are working for you?

    I am looking forward to your reply.

    Regards,
    Viktor Tachev
    Telerik
     

    Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

     
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017