Telerik is a leading vendor of ASP.NET AJAX, ASP.NET MVC, Silverlight, WinForms and WPF controls and components, as well as .NET Reporting, .NET ORM , .NET CMS, Code Analysis, Mocking, Team Productivity and Automated Testing Tools. Building on its expertise in interface development and Microsoft technologies, Telerik helps customers build applications with unparalleled richness, responsiveness and interactivity. Telerik products help thousands of companies to be more productive and deliver reliable applications under budget and on time.
Version Q2 2011 released 07/12/2011
select

Calendar / Sharing Calendars

Static shared calendar:

Departure
Arrival
Start date: End date:


Dynamic shared calendar:

Departure
Arrival
Start date: End date:


 

  • Having many date pickers on a page might render too much HTML and impact performance. RadDatePicker instances can share a RadCalendar control and use it to pick dates.

    There are two ways to configure the calendar control:
    • by setting its ID to the RadDatePicker.SharedCalendarID property. That can be done in the VS.NET designer.
    • by passing a reference of the control to the RadDatePicker.SharedCalendar property. Available to the code-behind logic only.

    This example page has four date pickers. The "static" ones have their SharedCalendarID property pointing at the "sharedCalendar" RadCalendar instance. The "dynamic" pickers are configured in the code-behind. The Page_Load event handler creates a new RadCalendar control and sets a reference to it to the pickers' SharedCalendar properties.

Source Code

C# VB.NET
Show code in new window Demo isolation steps
  • <%@ Page CodeFile="DefaultVB.aspx.vb" Language="vb" AutoEventWireup="false" Inherits="Telerik.Web.Examples.Calendar.Examples.Design.Sunny.DefaultVB" %>

    <%@ Register TagPrefix="telerik" Namespace="Telerik.Web.UI" Assembly="Telerik.Web.UI" %>
    <%@ Register TagPrefix="qsf" TagName="Header" Src="~/Common/Header.ascx" %>
    <%@ Register TagPrefix="qsf" TagName="HeadTag" Src="~/Common/HeadTag.ascx" %>
    <%@ Register TagPrefix="qsf" TagName="Footer" Src="~/Common/Footer.ascx" %>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head runat="server">
        <qsf:HeadTag runat="server" ID="Headtag1"></qsf:HeadTag>
        <style type="text/css">
            h5.rfdH5
            {
                font-size: 9pt;
                font-weight: normal;
                margin: 5px 0px 5px 0px;
            }
            h4.rfdH4
            {
                font-size: 11pt;
                font-weight: normal;
                margin: 5px 0px 5px 0px;
                border: none !important;
            }
        </style>
    </head>
    <body class="BODY">
        <form runat="server" id="mainForm" method="post">
        <qsf:Header ID="Header1" runat="server" NavigationLanguage="VB" ShowSkinChooser="true">
        </qsf:Header>
        <telerik:RadScriptManager ID="RadScriptManager1" runat="server" />
        <telerik:RadFormDecorator ID="RadFormDecorator1" runat="Server" DecoratedControls="All" />
        <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server">
            <AjaxSettings>
                <telerik:AjaxSetting AjaxControlID="Button1">
                    <UpdatedControls>
                        <telerik:AjaxUpdatedControl ControlID="Label1" />
                    </UpdatedControls>
                </telerik:AjaxSetting>
            </AjaxSettings>
        </telerik:RadAjaxManager>
        <div class="bigModule">
            <div class="bigModuleBottom">
                <table width="90%" style="margin: 25px auto 15px auto">
                    <tr>
                        <td colspan="4">
                            <h4>
                                Static shared calendar:</h4>
                        </td>
                    </tr>
                    <tr>
                        <td colspan="2" style="width: 50%">
                            <h5>
                                Departure</h5>
                        </td>
                        <td colspan="2" style="width: 50%">
                            <h5>
                                Arrival</h5>
                        </td>
                    </tr>
                    <tr>
                        <td>
                            Start date:
                        </td>
                        <td>
                            <telerik:RadDatePicker ID="RadDatePicker1" runat="server" MinDate="2006-01-01" SharedCalendarID="sharedCalendar"
                                Width="100px" ImagesPath="">
                            </telerik:RadDatePicker>
                        </td>
                        <td>
                            End date:
                        </td>
                        <td>
                            <telerik:RadDatePicker ID="RadDatePicker2" runat="server" MinDate="2006-01-01" SharedCalendarID="sharedCalendar"
                                Width="100px">
                            </telerik:RadDatePicker>
                        </td>
                    </tr>
                    <tr>
                        <td colspan="4">
                            <h4>
                                <br />
                                Dynamic shared calendar:</h4>
                        </td>
                    </tr>
                    <tr>
                        <td colspan="2" style="width: 50%">
                            <h5>
                                Departure</h5>
                        </td>
                        <td colspan="2" style="width: 50%">
                            <h5>
                                Arrival</h5>
                        </td>
                    </tr>
                    <tr>
                        <td>
                            Start date:
                        </td>
                        <td>
                            <telerik:RadDatePicker ID="RadDatePicker3" runat="server" MinDate="2006-01-01" Width="100px">
                            </telerik:RadDatePicker>
                        </td>
                        <td>
                            End date:
                        </td>
                        <td>
                            <telerik:RadDatePicker ID="RadDatePicker4" runat="server" MinDate="2006-01-01" Width="100px">
                            </telerik:RadDatePicker>
                        </td>
                    </tr>
                    <tr>
                        <td>
                            <br />
                            <asp:Button ID="Button1" runat="Server" Text="Make reservation" OnClick="Button1_Click" />
                        </td>
                        <td colspan="3">
    <asp:CompareValidator ID="CompareValidator1" runat="Server" ControlToCompare="RadDatePicker1"
    ControlToValidate="RadDatePicker2" Operator="GreaterThan" ErrorMessage=" *(<em>static</em>) Date range is not valid "

                                Display="Dynamic" />
    <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="Server" ControlToValidate="RadDatePicker1"
    ErrorMessage=" *(<em>static</em>) Departure date is not valid " Display="Dynamic"></asp:RequiredFieldValidator>

    <asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="Server" ControlToValidate="RadDatePicker2"
    ErrorMessage=" *(<em>static</em>) Arrival date is not valid " Display="Dynamic"></asp:RequiredFieldValidator>

                            <br />
    <asp:CompareValidator ID="CompareValidator2" runat="Server" ControlToCompare="RadDatePicker3"
    ControlToValidate="RadDatePicker4" Operator="GreaterThan" ErrorMessage=" *(<em>dynamic</em>) Date range is not valid "

                                Display="Dynamic" />
    <asp:RequiredFieldValidator ID="RequiredFieldValidator3" runat="Server" ControlToValidate="RadDatePicker3"
    ErrorMessage=" *(<em>dynamic</em>) Departure date is not valid " Display="Dynamic"></asp:RequiredFieldValidator>

    <asp:RequiredFieldValidator ID="RequiredFieldValidator4" runat="Server" ControlToValidate="RadDatePicker4"
    ErrorMessage=" *(<em>dynamic</em>) Arrival date is not valid " Display="Dynamic"></asp:RequiredFieldValidator>

                        </td>
                    </tr>
                </table>
                <asp:Label ID="Label1" Text="&nbsp;" runat="Server" Font-Italic="true" Style="padding-left: 38px" />
            </div>
        </div>
        <telerik:RadCalendar ID="sharedCalendar" runat="server" EnableMultiSelect="false"
            RangeMinDate="2006/01/01" />
        <asp:PlaceHolder ID="sharedCalendarPlaceHolder" runat="server"></asp:PlaceHolder>
        <qsf:Footer ID="Footer1" runat="server"></qsf:Footer>
        </form>
    </body>
    </html>

Get more than expected!

 
 

Take your time to truly experience the power of RadControls for ASP.NET AJAX with a free 60-day trial backed up by Telerik’s unlimited dedicated support.

Download your RadControls for ASP.NET AJAX trial and jumpstart your development with the available Getting Started resources.

If you have any questions, do not hesitate to contact us at sales@telerik.com.

Copyright 2002-2024 © Telerik. All right reserved
Telerik Inc, 201 Jones Rd, Waltham, MA 02451