Javascript problems with webservice demo in dynamic usercontrol

2 posts, 0 answers
  1. Roel
    Roel avatar
    2 posts
    Member since:
    Apr 2011

    Posted 17 Jan 2012 Link to this post

    Hi,

    I'm trying to get the RadScheduler demo with webservice binding to work in our application. If i recreate the demo in a new web application on an .aspx page everything works fine. But when i try to recreate it in a user control (which is dynamically loaded in our app) the javascript and jquery functions start acting up.

    it seems the $telerik.$find() function is not working. I've set all scriptreferences that are provided in the demo on my master page but once the function 'addCategoriesToArray' function fires the radPanelBar is not found. i've put the scripts inside a RadScriptBlock so the ClientID's are being resolved nicely.

    The first error i'm getting is: Cannot get the value of the property get_element: the object is null or not defined. This happens inside the following function:
    function addSelectedCategoriesToArray(categoryNamesArray) {
                var $ = $telerik.$;
                var categoryPanelBar = $find('<%=RadPanelBar1.ClientID %>');
                $(':checkbox:checked', categoryPanelBar.get_element()).each(function () {
                    categoryNames.push($(this).attr('name'));
                });
            }

    The panelbar is right there on the usercontrol and the id is the same as the resolved id the js is trying to find with $find.
    If i alert the categoryPanelbar var it's always null.

    Has anyone else encountered this issue and found a solution?


    Regards,
    Roel
  2. Ivana
    Admin
    Ivana avatar
    657 posts

    Posted 19 Jan 2012 Link to this post

    Hello,

    Try using the following approach to find the client-side object of the RadPanelBar:

    var paneljQuery = $telerik.$("[id$='_RadPanelBar1']");
    var panelBarObj = $find(paneljQuery.attr("id"));
    alert(panelBarObj.get_id());

    You could refer to this documentation section for more information of finding client objects when controls are placed in other controls.

    Kind regards,
    Ivana
    the Telerik team
    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 their blog feed now
Back to Top