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 Programming

Event Logger
Event log:

  • MonthYearPicker exposes a rich client-side API that allows you to control its behavior.

    You can manipulate the Min/MaxDate properties by the following client-side functions:
    • get_minDate( ) - Returns the date, representing the MinDate of the datepicker.
    • set_minDate(date) - if the date is valid, the datepicker MinDate is set to it.
    • get_maxDate( ) - Returns the date, representing the MaxDate of the datepicker.
    • set_maxDate(date) - if the date is valid, the datepicker MaxDate is set to it.

    You can manipulate the date selection by using the GetDate()/SetDate(newValue) method pair:
    var selectedDate = monthyearPicker.get_selectedDate();
    var year = (selectedDate.getFullYear() + 1);
    var month = (selectedDate.getMonth());
    var date = selectedDate.getDate();
    monthyearPicker.set_selectedDate(new Date(year, month, date));


    The datepicker child controls (RadDateInput and DatePopupButton) are available via the DateInput and DatePopupButton properties.

Source Code

C# VB.NET
Show code in new window Demo isolation steps
  • <%@ Page Language="vb" %>

    <%@ 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 runat="server" id="mainForm" method="post">
        <qsf:Header ID="Header1" runat="server" NavigationLanguage="VB"></qsf:Header>
        <!-- content start -->
        <telerik:RadScriptManager ID="RadScriptManager1" runat="server" />
        <telerik:RadCodeBlock ID="RadCodeBlock1" runat="server">
            <script type="text/javascript">
            //<![CDATA[
                function OnPopupOpening(sender, args) {
                    logEvent("OnPopupOpening fired by " + sender.get_id() + "<br />");
                }

                function OnPopupClosing(sender, args) {
                    logEvent("OnPopupClosing fired by " + sender.get_id() + "<br />");
                }
                function OnViewChanged(sender, args) {
                    logEvent("OnViewChanged fired by " + sender.get_id() + "<br />");
                }

                function OnDateSelected(sender, e) {
                    if (e.get_newDate() != null) {
                        logEvent("OnDateSelected: " + e.get_newDate().toDateString() + " selected in " + sender.get_id() + "<br />");
                    }
                    else {
                        logEvent("OnDateSelected: Date cleared in " + sender.get_id() + "<br />");
                    }
                }

                function onLoad(sender, args) {
                    logEvent("Date input " + sender.get_id() + " loaded <br />");
                }

                function NextYear(e) {
                    var monthyearPicker = $find("<%= RadMonthYearPicker1.ClientID %>");
                    var selectedDate = monthyearPicker.get_selectedDate();
                    if (selectedDate == null) {
                        alert("Select date!");
                        return false;
                    }
                    var year = (selectedDate.getFullYear() + 1);
                    var month = (selectedDate.getMonth());
                    var date = selectedDate.getDate();
                    monthyearPicker.set_selectedDate(new Date(year, month, date));
                    logEvent("MonthYearPicket.SelectedYear changed to " + monthyearPicker.get_selectedDate().format("MMM/yyyy") + "<br />");
                }

                function PrevYear(e) {
                    var monthyearPicker = $find("<%= RadMonthYearPicker1.ClientID %>"); ;
                    var selectedDate = monthyearPicker.get_selectedDate();
                    if (selectedDate == null) {
                        alert("Select date!");
                        return false;
                    }
                    var year = (selectedDate.getFullYear() - 1);
                    var month = (selectedDate.getMonth());
                    var date = selectedDate.getDate();
                    monthyearPicker.set_selectedDate(new Date(year, month, date));
                    logEvent("MonthYearPicket.SelectedYear changed to " + monthyearPicker.get_selectedDate().format("MMM/yyyy") + "<br />");
                }

                function setMinDate(minDate) {
                    var MonthYearPicker3 = $find("<%= RadMonthYearPicker3.ClientID %>");
                    if (minDate.checked) {
                        var date1 = new Date(2011, 0, 1);
                        MonthYearPicker3.set_minDate(date1);
                        logEvent("MonthYearPicker.MinDate changed to 01/2011 <br />");
                    }
                    else {
                        var date1 = new Date(1900, 0, 1);
                        MonthYearPicker3.set_minDate(date1);
                        logEvent("MonthYearPicker.MinDate changed to 01/1900 <br />");
                    }
                }

                function setMaxDate(maxDate) {
                    var date1 = new Date(2015, 11, 1);
                    var MonthYearPicker3 = $find("<%= RadMonthYearPicker3.ClientID %>");
                    if (maxDate.checked) {
                        MonthYearPicker3.set_maxDate(date1);
                        logEvent("MonthYear.MaxDate changed to 12/2015 <br />");
                    }
                    else {
                        var date1 = new Date(2050, 0, 1);
                        MonthYearPicker3.set_maxDate(date1);
                        logEvent("MonthYear.MaxDate changed to 01/2050 <br />");
                    }
                }

                function Enable(control) {
                    var MonthYearPicker3 = $find("<%= RadMonthYearPicker3.ClientID %>");
                    if (control.checked) {
                        MonthYearPicker3.set_enabled(true);
                        logEvent("MonthYearPicker Enabled <br />");
                    }
                    else {
                        MonthYearPicker3.set_enabled(false);
                        logEvent("MonthYearPicker Disabled <br />");
                    }
                }

                function clearText() {
                    var MonthYearPicker3 = $find("<%= RadMonthYearPicker3.ClientID %>");
                    MonthYearPicker3.clear();
                    logEvent("MonthYearPicker value cleared<br />");
                }
            //]]>
            </script>
        </telerik:RadCodeBlock>
        <div style="float: left">
            <fieldset style="width: 460px;">
                <legend>Select date:</legend>
                <telerik:RadMonthYearPicker ID="RadMonthYearPicker1" runat="server">
                    <ClientEvents OnViewChanged="OnViewChanged" OnPopupOpening="OnPopupOpening" OnPopupClosing="OnPopupClosing"
                        OnDateSelected="OnDateSelected"></ClientEvents>
                    <DateInput runat="server" ID="DateInput">
                        <ClientEvents OnLoad="onLoad" />
                    </DateInput>
                </telerik:RadMonthYearPicker>
                &nbsp;
                <input type="button" onclick="NextYear(event); return false;" value="Move to next year" />&nbsp;
                <input type="button" onclick="PrevYear(event); return false;" value="Move to previous year" />
                <br />
                <br />
            </fieldset>
            <fieldset style="width: 460px">
                <legend>Select Min/MaxDate for the RadMonthYearPciker: </legend>
                <div style="float: left;">
                    <telerik:RadMonthYearPicker ID="RadMonthYearPicker3" runat="server">
                        <ClientEvents OnViewChanged="OnViewChanged" OnPopupOpening="OnPopupOpening" OnPopupClosing="OnPopupClosing"
                            OnDateSelected="OnDateSelected"></ClientEvents>
                        <DateInput runat="server" ID="DateInput1">
                            <ClientEvents OnLoad="onLoad" />
                        </DateInput>
                    </telerik:RadMonthYearPicker>
                    <br />
    <asp:CheckBox runat="server" ID="Enabled" Checked="true" Text="RadDatePicker Enabled"
    onclick="Enable(this);" />

                    <br />
                    <input type="button" onclick="clearText(); return false;" value="Clear MonthYear value"/>
                </div>
                <div style="float: right;">
                    <br />
                    MinDate:<asp:CheckBox runat="server" ID="MinDate" Text="01/2011" onclick="setMinDate(this);" />
                    <br />
                    MaxDate:<asp:CheckBox runat="server" ID="MaxDate" Text="12/2015" onclick="setMaxDate(this);" />
                </div>
            </fieldset>
        </div>
        <table>
            <tr>
                <td style="vertical-align: top; width: 420px;">
                    <fieldset style="width: 280px; float: right;">
                        <legend>Event Logger </legend>
                        <qsf:EventLogConsole runat="server" ID="EventLogConsole1" />
                    </fieldset>
                </td>
            </tr>
        </table>
        <div style="clear: both">
        </div>
        <!-- content end -->
        <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