RadDatePicker - Min/Max Date don't update if ajaxified

2 posts, 0 answers
  1. Kris
    Kris avatar
    20 posts
    Member since:
    Jun 2010

    Posted 19 May 2015 Link to this post

    I have a date time picker which I've ajaxified using RadAjaxManager (and have tried using a RadAjaxPanel instead) but when ajaxified, the min/max dates don't update when set from code behind.  In my form, I have some dropdowns and based on what's selected I need to change what date range would be considered valid.  When I set the min/max date from the server side, it doesn't actually apply it (if you inspect the page you can still see the old min/max dates set).  If I remove the RadAjaxManager (or RadAjaxPanel) then it works fine.

     [code - Markup]

            <div class='col-md-1 text-right pull-left'>
                <asp:Label ID='lblPersonal_DoB' runat='server' Text='DoB' CssClass="label-middle-vertical" AssociatedControlID="dtPersonal_DoB" /> 
                <asp:Label ID='lblPersonal_Age' runat='server' Text='' CssClass="label-middle-vertical" />
            </div>
            <div class='col-md-2'>
                <telerik:RadDatePicker ID="dtPersonal_DoB" runat="server" CssClass='form-control' placeholder='DoB' Skin='Metro' aria-describedby='lblPersonal_DoB' AutoCompleteType="Disabled" DateInput-AutoCompleteType="Disabled" DateInput-CssClass="border-hide" OnSelectedDateChanged="dtPersonal_DoB_SelectedDateChanged" ClientEvents-OnDateSelected="dtPersonal_DoB_SelectedDateChanged" AutoPostBack="True" />

                <asp:RequiredFieldValidator ID="valPersonal_DoB" runat="server" ControlToValidate="dtPersonal_DoB" Display="Dynamic" ForeColor="Red" Text="* Required" ErrorMessage="Date of birth is required" ValidationGroup="PersonalInfo" Enabled="false" />
            </div>

    [/code]

    [code - Ajaxification]

    <telerik:RadAjaxManagerProxy runat="server" ID="ajaxManager_PersonalDetails">
        <AjaxSettings>
            <telerik:AjaxSetting AjaxControlID="dtPersonal_DoB">
                <UpdatedControls>
                    <telerik:AjaxUpdatedControl ControlID="lblPersonal_Age" />
                    <telerik:AjaxUpdatedControl ControlID="valPersonal_SSN" />
                    <telerik:AjaxUpdatedControl ControlID="txtPersonal_SSN" />
                </UpdatedControls>
            </telerik:AjaxSetting>
        </AjaxSettings>
    </telerik:RadAjaxManagerProxy>

    [/code]

    [code - Server side]

    if (value)
    {
    //If enabling SSN requirement then require being an adult
    dtPersonal_DoB.MinDate = (new DateTime(1901, 1, 1, 0, 0, 0));
    dtPersonal_DoB.MaxDate = DateTime.Now.Date.AddYears(-18);
    }
    else
    {
    //If disabling SSN requirement, then prevent entering an age of 21+
    dtPersonal_DoB.MinDate = DateTime.Now.Date.AddYears(-20);
    dtPersonal_DoB.MaxDate = DateTime.Now.Date;
    }

    [/code]

    Any ideas?

  2. Kris
    Kris avatar
    20 posts
    Member since:
    Jun 2010

    Posted 19 May 2015 in reply to Kris Link to this post

    Never mind, I figured out a solution.  I changed it to load the ajax settings from the code behind and do it on every page load and now it works as expected.
  3. UI for ASP.NET Ajax is Ready for VS 2017
Back to Top