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 Q1 2012 released 04/11/2012
select

Scheduler / Using Templates

previous daynext daytoday

Select date
<<<April 2012>>>
SMTWTFS
       
1234567
891011121314
15161718192021
22232425262728
2930     

Monday, April 16, 2012

all day
8AM
 
9AM
 
10AM
 
11AM
 
12PM
 
1PM
 
2PM
 
3PM
 
4PM
 
5PM
 
 
 

Technical Meeting

delete
 
 
 

Project "Alpha" Specifications Review

delete
 
 

Project "Alpha" Code Review

delete
 
 
 
 
 
 
 
 
 
 
Note: The changes in the data will be persisted per Session only. The data will be reset next time you visit the page.

  • You can use templates to customize the edit form and the way appointments are rendered in RadScheduler. This example uses the following:

    • AppointmentTemplate:   to customize the way appointments render.
    • InlineInsertTemplate:   to customize the inline insert form.
    • InlineEditTemplate:   to customize the inline edit form.
    • AdvancedEditTemplate:   to customize the advanced edit form.
    • AdvancedInsertTemplate:   to customize the advanced insert form.

    It also uses the FormCreated event to set default values of controls inside the templates.

    Important: For the sake of simplicity the advanced insert/edit templates in this example do not support Modal mode. Please see Use custom modal advanced template and the Advanced Templates demo for more information on how to enable such support in your templates.

Source Code

C# VB.NET
Show code in new window Demo isolation steps
  • <%@ Page Language="C#" AutoEventWireup="true" Inherits="Telerik.Web.Examples.Scheduler.Templates.DefaultCS"
        CodeFile="DefaultCS.aspx.cs" %>

    <%@ Register TagPrefix="telerik" Namespace="Telerik.Web.UI" Assembly="Telerik.Web.UI" %>
    <%@ Register TagPrefix="qsf" Namespace="Telerik.QuickStart" %>
    <%@ 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" %>
    <%@ Register TagPrefix="sds" Namespace="Telerik.Web.SessionDS" %>
    <!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 ID="Headtag1" runat="server" />
        <link rel="stylesheet" href="styles.css" type="text/css" />
        <script type="text/javascript">
            function pageLoad(sender, eventArgs) {
                // Prevent the double click event from bubbling out of the inline template
                $telerik.$(".rsAptEditSizingWrapper").bind("dblclick", function (e) { e.stopPropagation(); });
            }
        </script>
        <style type="text/css">
            .rsCustomAppointmentContainer div
            {
                width: 100% !important;
            }
            .rsCustomAppointmentContainer h2
            {
                overflow: hidden !important;
                white-space: nowrap !important;
                text-overflow: ellipsis !important;
            }
        </style>
    </head>
    <body class="BODY">
        <form id="Form1" method="post" runat="server">
        <qsf:Header ID="Header1" runat="server" NavigationLanguage="C#" />
        <telerik:RadScriptManager runat="server" ID="RadScriptManager1" />
        <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server">
            <AjaxSettings>
                <telerik:AjaxSetting AjaxControlID="RadScheduler1">
                    <UpdatedControls>
                        <telerik:AjaxUpdatedControl ControlID="RadScheduler1" LoadingPanelID="RadAjaxLoadingPanel1" />
                    </UpdatedControls>
                </telerik:AjaxSetting>
            </AjaxSettings>
        </telerik:RadAjaxManager>
        <telerik:RadAjaxLoadingPanel ID="RadAjaxLoadingPanel1" runat="server" />
        <telerik:RadScheduler runat="server" ID="RadScheduler1" SelectedDate="2012-04-16"
            DayStartTime="08:00:00" DayEndTime="18:00:00" ShowViewTabs="false" StartEditingInAdvancedForm="false"
            DataSourceID="AppointmentsDataSource" DataKeyField="ID" DataSubjectField="Subject"
            DataStartField="Start" DataEndField="End" DataRecurrenceField="RecurrenceRule"
            DataRecurrenceParentKeyField="RecurrenceParentID" OnAppointmentCommand="RadScheduler1_AppointmentCommand"
            OnFormCreated="RadScheduler1_FormCreated" OnFormCreating="RadScheduler1_FormCreating"
            OnAppointmentCreated="RadScheduler1_AppointmentCreated">
            <ResourceTypes>
                <telerik:ResourceType KeyField="ID" Name="AppointmentType" TextField="Keyword" ForeignKeyField="AppointmentTypeID"
                    DataSourceID="AppointmentTypesDataSource" />
            </ResourceTypes>
            <ResourceStyles>
                <telerik:ResourceStyleMapping Type="AppointmentType" Text="technical" ApplyCssClass="rsCategoryGreen" />
                <telerik:ResourceStyleMapping Type="AppointmentType" Text="specification_review"
                    ApplyCssClass="rsCategoryOrange" />
                <telerik:ResourceStyleMapping Type="AppointmentType" Text="code_review" ApplyCssClass="rsCategoryBlue" />
            </ResourceStyles>
            <InlineInsertTemplate>
                <div id="InlineInsertTemplate" class="rsCustomAppointmentContainer technical">
                    <div>
                    </div>
                    <span class="rsCustomAppointmentContainerInner">
                        <asp:TextBox ID="TitleTextBox" runat="server" Text='<%# Bind("Subject") %>' Width="90%"
                            TextMode="MultiLine" Height="20px"></asp:TextBox>
                        <asp:LinkButton ID="InsertButton" runat="server" CommandName="Insert">
                            <asp:Image runat="server" ID="insertImage" ImageUrl="Images/ok.png" AlternateText="insert" />
                        </asp:LinkButton>
                        <asp:LinkButton ID="InsertCancelButton" runat="server" CausesValidation="False" CommandName="Cancel">
                            <asp:Image runat="server" ID="Image2" ImageUrl="Images/cancel.png" AlternateText="cancel" />
                        </asp:LinkButton>
                        <span class="inline-label">Color code:</span>
    <asp:RadioButtonList runat="server" ID="AppointmentTypeRadioButtonList" DataValueField="ID"
    CssClass="AppointmentTypeSelectorTable" DataSourceID="AppointmentTypesDataSource"
    SelectedValue='<%# Bind("AppointmentTypeID") %>' DataTextField="Keyword" RepeatDirection="Horizontal"

                            DataTextFormatString="<span class='AppointmentTypeSelector rsAptType_{0}'></span>">
                        </asp:RadioButtonList>
                        <asp:LinkButton ID="InsertMoreButton" runat="server" CommandName="More" CssClass="rsAdvancedEditLink">Advanced</asp:LinkButton>
                    </span>
                </div>
            </InlineInsertTemplate>
            <InlineEditTemplate>
                <div id="InlineEditTemplate" class="rsCustomAppointmentContainer <%# Eval("AppointmentType.Text") %>">
                    <div>
                    </div>
                    <span class="rsCustomAppointmentContainerInner">
                        <asp:TextBox ID="TitleTextBox" runat="server" Text='<%# Bind("Subject") %>' Width="90%"
                            TextMode="MultiLine" Height="20px"></asp:TextBox>
                        <asp:LinkButton ID="InsertButton" runat="server" CommandName="Update">
                            <asp:Image runat="server" ID="insertImage" ImageUrl="Images/ok.png" AlternateText="update" />
                        </asp:LinkButton>
                        <asp:LinkButton ID="InsertCancelButton" runat="server" CausesValidation="False" CommandName="Cancel">
                            <asp:Image runat="server" ID="Image3" ImageUrl="Images/cancel.png" AlternateText="cancel" />
                        </asp:LinkButton>
                        <span class="inline-label">Color code:</span>
    <asp:RadioButtonList runat="server" ID="AppointmentTypeRadioButtonList" DataValueField="ID"
    CssClass="AppointmentTypeSelectorTable" DataSourceID="AppointmentTypesDataSource"
    SelectedValue='<%# Bind("AppointmentTypeID") %>' DataTextField="Keyword" RepeatDirection="Horizontal"

                            DataTextFormatString="<span class='AppointmentTypeSelector rsAptType_{0}'></span>">
                        </asp:RadioButtonList>
                        <asp:LinkButton ID="InsertMoreButton" runat="server" CommandName="More" CssClass="rsAdvancedEditLink">Advanced</asp:LinkButton>
                    </span>
                </div>
            </InlineEditTemplate>
            <AppointmentTemplate>
                <div class="rsCustomAppointmentContainer <%# Eval("AppointmentType.Text") %>">
                    <h2>
                        <%# Eval("Subject") %>
                    </h2>
                    <div>
                    </div>
                </div>
            </AppointmentTemplate>
            <AdvancedEditTemplate>
                <div id="qsfexAdvEditWrapper">
                    <div id="qsfexAdvEditInnerWrapper" class='<%# Eval("AppointmentType.Text") %>'>
                        <div class="qsfexAdvAppType">
                        </div>
                        <div class="qsfexAdvEditControlWrapper">
                            <asp:Label AssociatedControlID="TitleTextBox" runat="server" CssClass="inline-label">Description</asp:Label>
                            <asp:TextBox ID="TitleTextBox" Rows="5" Columns="20" runat="server" Text='<%# Bind("Subject") %>'
                                Width="97%" TextMode="MultiLine"></asp:TextBox><br />
                        </div>
                        <div class="qsfexAdvEditControlWrapper">
                            <asp:Label AssociatedControlID="StartInput" runat="server" CssClass="inline-label">Start time:</asp:Label>
                            <telerik:RadDateInput ID="StartInput" SelectedDate='<%# Bind("Start") %>' runat="server" _EnableOldBoxModel="true"
                            EnableSingleInputRendering="false"
                            >
                            </telerik:RadDateInput><br />
                        </div>
                        <div class="qsfexAdvEditControlWrapper">
                            <asp:Label AssociatedControlID="EndInput" runat="server" CssClass="inline-label">End time:</asp:Label>
                            <telerik:RadDateInput ID="EndInput" SelectedDate='<%# Bind("End") %>' runat="server" EnableSingleInputRendering="false">
                            </telerik:RadDateInput><br />
                        </div>
                        <div class="qsfexAdvEditControlWrapper">
                            <div class="inline-label">
                                Color code:</div>
                            <div id="qsfexAdvEditColorCodeChooser">
    <asp:RadioButtonList runat="server" ID="AppointmentTypeRadioButtonList" DataValueField="ID"
    CssClass="AppointmentTypeSelectorTable" DataSourceID="AppointmentTypesDataSource"
    SelectedValue='<%# Bind("AppointmentTypeID") %>' DataTextField="Keyword" RepeatDirection="Horizontal"

                                    DataTextFormatString="<span class='AppointmentTypeSelector rsAptType_{0}'></span>">
                                </asp:RadioButtonList>
                            </div>
                        </div>
                        <div class="qsfexAdvEditControlWrapper">
                            <asp:CheckBox ID="RepeatCheckBox" runat="server" Text="Repeat for 10 days" CssClass="repeatCheckBox" />
                        </div>
                        <div class="qsfexAdvEditControlWrapper" style="text-align: right;">
                            <asp:LinkButton ID="UpdateButton" runat="server" CommandName="Update">
                                <asp:Image runat="server" ID="insertImage" ImageUrl="Images/ok.png" AlternateText="update" /></asp:LinkButton>
    <asp:LinkButton ID="UpdateCancelButton" runat="server" CausesValidation="False" CommandName="Cancel"
    Style="margin-right: 8px;">

                                <asp:Image runat="server" ID="Image2" ImageUrl="Images/cancel.png" AlternateText="cancel" /></asp:LinkButton>
                        </div>
                    </div>
                </div>
            </AdvancedEditTemplate>
            <AdvancedInsertTemplate>
                <div id="qsfexAdvEditWrapper">
                    <div id="qsfexAdvEditInnerWrapper" class="technical">
                        <div class="qsfexAdvAppType">
                        </div>
                        <div class="qsfexAdvEditControlWrapper">
                            <asp:Label AssociatedControlID="TitleTextBox" runat="server" CssClass="inline-label">Description</asp:Label>
                            <asp:TextBox ID="TitleTextBox" Rows="5" Columns="20" runat="server" Text='<%# Bind("Subject") %>'
                                Width="97%" TextMode="MultiLine"></asp:TextBox><br />
                        </div>
                        <div class="qsfexAdvEditControlWrapper">
                            <asp:Label AssociatedControlID="StartInput" runat="server" CssClass="inline-label">Start time:</asp:Label>
                            <telerik:RadDateInput ID="StartInput" SelectedDate='<%# Bind("Start") %>' runat="server" EnableSingleInputRendering="false">
                            </telerik:RadDateInput><br />
                        </div>
                        <div class="qsfexAdvEditControlWrapper">
                            <asp:Label AssociatedControlID="EndInput" runat="server" CssClass="inline-label">End time:</asp:Label>
                            <telerik:RadDateInput ID="EndInput" SelectedDate='<%# Bind("End") %>' runat="server" EnableSingleInputRendering="false">
                            </telerik:RadDateInput><br />
                        </div>
                        <div class="qsfexAdvEditControlWrapper">
                            <div class="inline-label">
                                Color code:</div>
                            <div id="qsfexAdvEditColorCodeChooser">
    <asp:RadioButtonList runat="server" ID="AppointmentTypeRadioButtonList" DataValueField="ID"
    CssClass="AppointmentTypeSelectorTable" DataSourceID="AppointmentTypesDataSource"
    SelectedValue='<%# Bind("AppointmentTypeID") %>' DataTextField="Keyword" RepeatDirection="Horizontal"

                                    DataTextFormatString="<span class='AppointmentTypeSelector rsAptType_{0}'></span>">
                                </asp:RadioButtonList>
                            </div>
                        </div>
                        <div class="qsfexAdvEditControlWrapper">
                            <asp:CheckBox ID="RepeatCheckBox" runat="server" Text="Repeat for 10 days" CssClass="repeatCheckBox" />
                        </div>
                        <div class="qsfexAdvEditControlWrapper" style="text-align: right;">
                            <asp:LinkButton ID="InsertButton" runat="server" CommandName="Insert">
                                <asp:Image runat="server" ID="Image4" ImageUrl="Images/ok.png" AlternateText="update" /></asp:LinkButton>
    <asp:LinkButton ID="InsertCancelButton" runat="server" CausesValidation="False" CommandName="Cancel"
    Style="margin-right: 8px;">

                                <asp:Image runat="server" ID="Image5" ImageUrl="Images/cancel.png" AlternateText="cancel" /></asp:LinkButton>
                        </div>
                    </div>
                </div>
            </AdvancedInsertTemplate>
            <TimeSlotContextMenuSettings EnableDefault="true" />
            <AppointmentContextMenuSettings EnableDefault="true" />
        </telerik:RadScheduler>
        <sds:SessionDataSource ID="AppointmentsDataSource" runat="server" DisplayWarning="true"
            PrimaryKeyFields="ID" ProviderName="System.Data.SqlClient" ConnectionString="<%$ ConnectionStrings:TelerikConnectionString %>"
            SelectCommand="SELECT * FROM [Templates_Appointments]" InsertCommand="INSERT INTO [Templates_Appointments] ([Subject], [Start], [End], [AppointmentTypeID], [RecurrenceRule], [RecurrenceParentID]) VALUES (@Subject, @Start, @End, @AppointmentTypeID, @RecurrenceRule, @RecurrenceParentID)"
            UpdateCommand="UPDATE [Templates_Appointments] SET [Subject] = @Subject, [Start] = @Start, [End] = @End, [AppointmentTypeID] = @AppointmentTypeID, [RecurrenceRule] = @RecurrenceRule, [RecurrenceParentID] = @RecurrenceParentID WHERE (ID = @ID)"
            DeleteCommand="DELETE FROM [Templates_Appointments] WHERE [ID] = @ID">
            <DeleteParameters>
                <asp:Parameter Name="ID" Type="Int32" />
            </DeleteParameters>
            <UpdateParameters>
                <asp:Parameter Name="ID" Type="Int32" />
                <asp:Parameter Name="Subject" Type="String" />
                <asp:Parameter Name="Start" Type="DateTime" />
                <asp:Parameter Name="End" Type="DateTime" />
                <asp:Parameter Name="AppointmentTypeID" Type="Int32" />
                <asp:Parameter Name="RecurrenceRule" Type="String" />
                <asp:Parameter Name="RecurrenceParentID" Type="Int32" />
            </UpdateParameters>
            <InsertParameters>
                <asp:Parameter Name="Subject" Type="String" />
                <asp:Parameter Name="Start" Type="DateTime" />
                <asp:Parameter Name="End" Type="DateTime" />
                <asp:Parameter Name="AppointmentTypeID" Type="Int32" />
                <asp:Parameter Name="RecurrenceRule" Type="String" />
                <asp:Parameter Name="RecurrenceParentID" Type="Int32" />
            </InsertParameters>
        </sds:SessionDataSource>
        <sds:SessionDataSource ID="AppointmentTypesDataSource" runat="server" DisplayWarning="false"
            ProviderName="System.Data.SqlClient" ConnectionString="<%$ ConnectionStrings:TelerikConnectionString %>"
            SelectCommand="SELECT * FROM [Templates_AppointmentTypes]">
        </sds:SessionDataSource>
        <qsf:Footer runat="server" ID="Footer1" />
        </form>
        <script type="text/javascript">
            var $ = $telerik.$;

            // Toggles the inline form style when choosing a resource from the radio buttons.
            $('.AppointmentTypeSelectorTable input[type=radio]').live('click',
                function () {
                    appType = $('input ~ label > span', this.parentNode)[0].className.match(/rsAptType_(.+?)\b/i)[1];

                    var parentElement = $(this).parents('.rsCustomAppointmentContainer');
                    if (parentElement.length == 0) {
                        var parentElement = $(this).parents('#qsfexAdvEditInnerWrapper');

                        if (parentElement.length == 0)
                            return;

                        parentElement.attr('className', appType);
                    } else {
                        parentElement.attr('className', 'rsCustomAppointmentContainer ' + appType);
                    }

                });
        </script>
    </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-2012 © Telerik. All right reserved
Telerik Inc, 201 Jones Rd, Waltham, MA 02451