New to Telerik UI for ASP.NET AJAX? Download free 30-day trial

Server-Side Events

RadRangeDatePicker

Event log
In this example we demonstrate the RangeSelectionChanged server-side event of the RadDateRangePicker:
  • RangeSelectionChanged - it fires on postback, only if the Start or/and End dates have been changed.
In the demo we have used the DateSelected client-side event and the set_shouldPostback() function exposed in the EventArguments object to automaticaly trigger a postback and submit the changes to the server when both Start and End date have been selected.

function OnDateSelected(sender, args) {
    //trigger a postback when both start and end dates are selected
    if (sender.get_rangeSelectionStartDate() && sender.get_rangeSelectionEndDate()) {
        args.set_shouldPostBack(true);
    }
}

You can use the Submit button to commit the changes to the server when either Start or End date (or both) is not selected.
  • DefaultVB.aspx
  • DefaultVB.aspx.vb
<%@ Page CodeFile="DefaultVB.aspx.vb" Language="vb" Inherits="Telerik.Web.Examples.DateRangePicker.ServerSideEvents.DefaultVB" %>

<%@ Register TagPrefix="telerik" Namespace="Telerik.Web.UI" Assembly="Telerik.Web.UI" %>
<%@ Register TagPrefix="qsf" Namespace="Telerik.QuickStart" %>
<!DOCTYPE html>
<html xmlns='http://www.w3.org/1999/xhtml'>
<head runat="server">
    <title>Telerik ASP.NET Example</title>
</head>
<body>
    <form id="form1" runat="server">
    <telerik:RadScriptManager runat="server" ID="RadScriptManager1" />
    <telerik:RadSkinManager ID="RadSkinManager1" runat="server" ShowChooser="true" />
    <div class="demo-container size-narrow" runat="server" id="containerDiv">
        <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server" UpdatePanelsRenderMode="Inline">
            <AjaxSettings>
                <telerik:AjaxSetting AjaxControlID="RadDateRangePicker1">
                    <UpdatedControls>
                        <telerik:AjaxUpdatedControl ControlID="RadDateRangePicker1"></telerik:AjaxUpdatedControl>
                        <telerik:AjaxUpdatedControl ControlID="RadButton1"></telerik:AjaxUpdatedControl>
                        <telerik:AjaxUpdatedControl ControlID="EventLogConsole1"></telerik:AjaxUpdatedControl>
                    </UpdatedControls>
                </telerik:AjaxSetting>
                <telerik:AjaxSetting AjaxControlID="RadButton1">
                    <UpdatedControls>
                        <telerik:AjaxUpdatedControl ControlID="RadDateRangePicker1"></telerik:AjaxUpdatedControl>
                        <telerik:AjaxUpdatedControl ControlID="RadButton1"></telerik:AjaxUpdatedControl>
                        <telerik:AjaxUpdatedControl ControlID="EventLogConsole1"></telerik:AjaxUpdatedControl>
                    </UpdatedControls>
                </telerik:AjaxSetting>
            </AjaxSettings>
        </telerik:RadAjaxManager>
        <style>
            html body div.RadDateRangePicker {
                display: inline-block;
            }
        </style>
        <h3>RadRangeDatePicker</h3>
        <script>
            function OnDateSelected(sender, args) {
                // trigger a postback when both start and end dates are selected
                if (sender.get_rangeSelectionStartDate() && sender.get_rangeSelectionEndDate()) {
                    args.set_shouldPostBack(true);
                }
            }
        </script>
        <telerik:RadDateRangePicker RenderMode="Lightweight" runat="server" ID="RadDateRangePicker1" AutoPostBack="true" OnRangeSelectionChanged="RadDateRangePicker1_RangeSelectionChanged">
            <ClientEvents OnDateSelected="OnDateSelected" />
        </telerik:RadDateRangePicker>
        <telerik:RadButton runat="server" ID="RadButton1" Text="Submit" AutoPostBack="true" />
    </div>
    <qsf:EventLogConsole runat="server" ID="EventLogConsole1"></qsf:EventLogConsole>
    </form>
</body>
</html>

Support & Learning Resources

Find Assistance