This is a migrated thread and some comments may be shown as answers.

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

1 Answer 40 Views
Calendar
This is a migrated thread and some comments may be shown as answers.
Bruce
Top achievements
Rank 1
Bruce asked on 03 Oct 2013, 08:16 PM
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>

1 Answer, 1 is accepted

Sort by
0
Konstantin Dikov
Telerik team
answered on 08 Oct 2013, 12:24 PM
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.
Tags
Calendar
Asked by
Bruce
Top achievements
Rank 1
Answers by
Konstantin Dikov
Telerik team
Share this question
or