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 / Client-side API




Select time:



MinDate(Time):
MaxDate(Time):


Event log:

  • RadTimePicker exposes rich client-side API set which allows easy and flexible use in a wide range of application scenarios. In this example we demonstrate the main client-side functions:

    TimePicker
    • showTimePopup
    • hideTimePopup
    • get_timeView()

    • set_enabled()
    • set_minDate()
    • set_maxDate()
    TimeView
    • setTime
    • getTime
    • get_oldTime
    • get_newTime

Source Code

C# VB.NET
Show code in new window Demo isolation steps
  • <%@ Page Language="vb" CodeFile="DefaultVB.aspx.vb" AutoEventWireup="false" Inherits="Telerik.Web.Examples.Calendar.DateTimePicker.ClientAPI.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" %>
    <%@ Register TagPrefix="qsf" Namespace="Telerik.QuickStart" %>
    <!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>
    </head>
    <body class="BODY">
        <form id="Form1" method="post" runat="server">
        <qsf:Header ID="Header1" runat="server" NavigationLanguage="VB"></qsf:Header>
        <telerik:RadScriptManager ID="RadScriptManager1" runat="server" />
        <telerik:RadCodeBlock ID="RadCodeBlock1" runat="server">
            <script type="text/javascript">
             //<![CDATA[
                function ClientTimeSelected(sender, e)
                {
                    var oldTime = e.get_oldTime() ? (e.get_oldTime().getHours() + ":" + e.get_oldTime().getMinutes()) : "";
                    var newTime = e.get_newTime() ? (e.get_newTime().getHours() + ":" + e.get_newTime().getMinutes()) : "";
                    var info = "OnClientTimeSelected: " + "oldTime-> " + oldTime + ", newTime-> " + newTime;
                    logEvent(info);
                }
                function NextTime()
                {
                    var timePicker = $find("<%= RadTimePicker1.ClientID %>");
                    var timeView = timePicker.get_timeView();
                    var time = timeView.getTime();

                    if (time == null)
                        time = new Date();

                    var interval = timeView.get_interval();
                    timeView.setTime(time.getHours() + interval.getHours(),
                                 time.getMinutes() + interval.getMinutes(),
                                 time.getSeconds() + interval.getSeconds(),
                                 time);
                    logEvent("NextTime: " + "Interval: " +
                                    interval.getHours() + ":" +
                                    interval.getMinutes() + ":" +
                                    interval.getSeconds());
                }
                function PopupAbove(e)
                {
                    var timePicker = $find("<%= RadTimePicker1.ClientID %>");
                    timePicker.set_popupDirection(12); // Set the popup dierction to TopRight
                    timePicker.showTimePopup();
                    timePicker.set_popupDirection(22); // Set the popup dierction back to default (BottomRight)
                }

                function Enable(control)
                {
                    var timePicker = $find("<%= RadTimePicker1.ClientID %>");
                    if (control.checked)
                    {
                        timePicker.set_enabled(true);
                        timePicker.get_timePopupButton().className = "rcTimePopup";
                        logEvent("RadTimePicker Enabled");
                    }
                    else
                    {
                        timePicker.set_enabled(false);
                        timePicker.get_timePopupButton().className = "rcTimePopup rcDisabled";
                        logEvent("RadTimePicker Disabled");
                    }
                }


                function clearText()
                {
                    var timePicker = $find("<%= RadTimePicker1.ClientID %>");
                    timePicker.clear();
                    logEvent("RadTimePicker value cleared");
                }

                function setMinDate(minDate)
                {
                    var timePicker = $find("<%= RadTimePicker1.ClientID %>");
                    if (minDate.checked)
                    {
                        var date1 = new Date();
                        date1.setHours(5, 0, 0, 0);
                        timePicker.set_minDate(date1);
                        logEvent("RadTimePicker1.MinDate changed to 5:00 AM");
                    }
                    else
                    {
                        var date1 = new Date();
                        date1.setHours(0, 0, 0, 0);
                        timePicker.set_minDate(date1);
                        logEvent("RadTimePicker1.MinDate removed");
                    }
                }

                function setMaxDate(maxDate)
                {
                    var date1 = new Date();
                    date1.setHours(20, 0, 0, 0);
                    var timePicker = $find("<%= RadTimePicker1.ClientID %>");
                    if (maxDate.checked)
                    {
                        timePicker.set_maxDate(date1);
                        logEvent("RadTimePicker1.MaxDate changed to 08:00 PM");
                    }
                    else
                    {
                        var date1 = new Date();
                        date1.setHours(24, 0, 0, 0);
                        timePicker.set_maxDate(date1);
                        logEvent("RadTimePicker1.MaxDate removed");
                    }
                }
            //]]>
            </script>
        </telerik:RadCodeBlock>
        <telerik:RadFormDecorator ID="RadFormDecorator1" runat="server" DecoratedControls="Buttons" />
        <br />
        <br />
        <br />
        <asp:Panel ID="Panel1" runat="server">
            <fieldset>
                Select time:
                <telerik:RadTimePicker ID="RadTimePicker1" runat="server" ZIndex="30001">
                    <TimeView ID="TimeView1" runat="server" OnClientTimeSelected="ClientTimeSelected">
                    </TimeView>
                </telerik:RadTimePicker>
                <table>
                    <tr>
                        <td style="width: 250px;">
                            <button onclick="javascript: PopupAbove(event); return false;" style="width: 130px">
                                Popup above input</button><br />
                            <button onclick="javascript: NextTime(); return false;" style="width: 130px">
                                Move to next hour</button><br />
                            <button onclick="javascript: clearText(); return false;" style="width: 130px">
                                Clear DatePicker value</button>
                        </td>
                        <td style="width: 250px;">
    <asp:CheckBox runat="server" ID="Enabled" Checked="true" Text="RadTimePicker Enabled"
    onclick="Enable(this);" />

                            <br />
                            MinDate(Time):<asp:CheckBox runat="server" ID="MinDate" Text="05:00 AM" onclick="setMinDate(this);" />
                            <br />
                            MaxDate(Time):<asp:CheckBox runat="server" ID="MaxDate" Text="08:00 PM" onclick="setMaxDate(this);" />
                            <br />
                        </td>
                        <td>
                        </td>
                    </tr>
                </table>
            </fieldset>
            <br />
            <br />
            <qsf:EventLogConsole runat="server" ID="EventLogConsole1" />
        </asp:Panel>
        <qsf:Footer ID="Footer2" 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