$find not working

7 posts, 1 answers
  1. Eduardo
    Eduardo avatar
    30 posts
    Member since:
    Feb 2009

    Posted 20 May 2009 Link to this post

    Hi,

    Am I missing something? The $find is not working for a RadPanelBar, here is the code:

    ... 
    <body topmargin="0" leftmargin="0"
        <form id="form1" runat="server"
        <div> 
            <telerik:RadScriptManager ID="RadScriptManager1" runat="server"
            </telerik:RadScriptManager> 
            <telerik:RadPanelBar ID="rpbNavigation" runat="server" style="width:100%" Skin="Outlook" EnableViewState="false"
            </telerik:RadPanelBar> 
        </div> 
        </form> 
        <telerik:RadCodeBlock ID="RadCodeBlock2" runat="server"
            <script type="text/javascript"
                checkMain(); 
                function checkMain() { 
                    var panelBar = $find("<%= rpbNavigation.ClientID %>"); 
     
                    var item = panelBar.findItemByText(Main.selectedModule); 
                } 
            </script> 
        </telerik:RadCodeBlock> 
    </body> 
    ... 

    I tried to put the script block on the header tag and in the body tag. If I replace by $get, it works, but then I can't access the findItemByText function. The funny thing is that I use a very similar code on other page and it works, the difference is that I use a RadMenu instead a RadPanelBar.

    On, the call to checkMain() would be on the onload event of the body, I tried to move around to see if there was something to do with the timing of this call, but no luck.

    Any help is appreciated.

    Thanks,
    Eduardo
  2. Answer
    Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 20 May 2009 Link to this post

    Hello Eduardo,

    In ASP.NET AJAX environment, the ASP.NET AJAX controls (including RadControls for ASP.NET AJAX) are created after the page has been loaded. That's why you are not getting client side object of RadPanelBar. In order to get the client side object of RadControls when page loads, you can create function that use the reserved name pageLoad() (which fires when page loads) and inside that you can access the client side object for each control. Try the following approach.

    JavaScript:
     
    <script type="text/javascript"
    function pageLoad() 
        checkMain();  
    function checkMain() 
    {  
        var panelBar = $find("<%= rpbNavigation.ClientID %>"); 
        var item = panelBar.findItemByText('TextToFind');  
        alert(item.get_text()); 
    }  
    </script> 

    Regards,
    Shinu.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Eduardo
    Eduardo avatar
    30 posts
    Member since:
    Feb 2009

    Posted 21 May 2009 Link to this post

    Thanks a lot, you are a genius :-)

    Eduardo
  5. tmlipinski
    tmlipinski avatar
    131 posts
    Member since:
    Dec 2006

    Posted 25 May 2009 Link to this post

    Hi,

    It is the first time I've learnt about "pageLoad" reserved function name. Where does it come from? Is this reserved name (and other reserved names of this kind?) described anywhere? I've tried to "google" it but with no success.
    The same applies to the $find function.

    Can you link me to any kind of documentation of that?
    Thank you in advance.

    Regards
    Tomasz
  6. Paul
    Admin
    Paul avatar
    4281 posts

    Posted 25 May 2009 Link to this post

    Hi Tomasz,

    pageLoad() is a shortcut for the Sys.Application.load event. For details on the matter please refer to the following ASP.NET article.

    Regards,
    Paul
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
  7. tmlipinski
    tmlipinski avatar
    131 posts
    Member since:
    Dec 2006

    Posted 25 May 2009 Link to this post

    Thanks a lot.
    Tomasz
  8. Lorenzo
    Lorenzo avatar
    42 posts
    Member since:
    Jul 2009

    Posted 08 Mar 2011 Link to this post

    I agree with Eduardo...you are a genius !!!!!

    Thanks
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017