OnPopupOpening Event Causes (method) is undefined error after adding RadAjaxManger to parent RadGrid

2 posts, 0 answers
  1. Bruce
    Bruce avatar
    17 posts
    Member since:
    Mar 2013

    Posted 03 Oct 2013 Link to this post

    I have a RadGrid list of staff members that opens a web user control for editing. The edit control has a RadDatePicker for selecting a birthdate, and I set the control to today - 21 years when opened if the date picker control is blank. All of this was working fine until I added a RadAjaxManager and paging to my RadGrid. I can remove the RadAjaxManager code from the RadGrid and the OnPopupOpening event works again. Can't I have both ajax enabled paging and be able to set the default date.

    Here is my ascx code for the RadGrid list control.
    <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server">
        <AjaxSettings>
            <telerik:AjaxSetting AjaxControlID="uxStaffList">
                <UpdatedControls>
                    <telerik:AjaxUpdatedControl ControlID="uxStaffList" />
                </UpdatedControls>
            </telerik:AjaxSetting>
        </AjaxSettings>
    </telerik:RadAjaxManager>
    <cc1:IbsRadGridList ID="uxStaffList" runat="server"
        Factory="StaffFactory"
        AllowPaging="true"
        PageSize="20"
        DeleteButtonVisible="false">
        <MasterTableView DataKeyNames="StaffId">
            <EditFormSettings UserControlName="StaffEditControl.ascx" PopUpSettings-Width="940px" CaptionDataField="FullName"></EditFormSettings>
        </MasterTableView>
    </cc1:IbsRadGridList>
    Here are the relevant snippets from my edit control.
                ...
                <div class="control-group">
                    <asp:Label ID="BirthDateLabel" runat="server" CssClass="control-label" AssociatedControlID="uxBirthDate">Birthday</asp:Label>
                    <div class="controls">
                        <telerik:RadDatePicker ID="uxBirthdate" runat="server" MinDate="1/1/1913" ClientEvents-OnPopupOpening="setDefaultBirthDate"></telerik:RadDatePicker>
                    </div>
                </div>
               ...
     
    <script type="text/javascript">
        function setDefaultBirthDate(sender, e) {
            if (sender.isEmpty()) {
                var d = new Date();
                d.setFullYear(d.getFullYear() - 21);
                sender.set_selectedDate(d);
            }
        }
    </script>
  2. Konstantin Dikov
    Admin
    Konstantin Dikov avatar
    1793 posts

    Posted 08 Oct 2013 Link to this post

    Hi Bruce,

    Thank you for contacting Telerik Support.

    If you want to place the JavaScript inside the user control markup, and you are using AJAX, you need to put your code inside a RadScriptBlock control, so the the script gets properly registered on page after AJAX. For more information:

    Please replace your JavaScript in the UserControl with the following and see if it solves the issue:
    <telerik:RadScriptBlock ID="RadScriptBlock1" runat="server">
        <script type="text/javascript">
            function setDefaultBirthDate(sender, e) {
                if (sender.isEmpty()) {
                    var d = new Date();
                    d.setFullYear(d.getFullYear() - 21);
                    sender.set_selectedDate(d);
                }
            }
        </script>
    </telerik:RadScriptBlock>

    If further assistance is needed, please feel free to contact us again.

     

    Regards,
    Konstantin Dikov
    Telerik
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to the blog feed now.
  3. UI for ASP.NET Ajax is Ready for VS 2017
Back to Top