Telerik
Skip Navigation LinksHome / Community / Forums / ASP.NET > Panelbar > Get control contained in RadPanelBar RadPanelItem via javascript/client side

Not answered Get control contained in RadPanelBar RadPanelItem via javascript/client side

Feed from this thread
  • Seth Intermediate avatar

    Posted on Mar 20, 2008 (permalink)

    I have a control in one of my RadPanelItems that I need to access in my client side javascript code.  How can I get a reference to it?

    I've tried:

    var myCtrl = <%= Control.ClientID %>;
    var myCtrl = $find("Control");
    var myCtrl = document.getElementById("Control");
    var myCtrl = myPanelBar.Items[0].Items[0].Controls[1];

    No luck so far.

    Thanks.

    Reply

  • Telerik Admin admin's avatar

    Posted on Mar 21, 2008 (permalink)

    Hi Seth,

    I reviewed your account and it seemed that you've been evaluating our products for almost an year. Could you share with us how your evaluation is going? Any feedback on our products (installation, ease of use, documentation) will help us in providing better products and services in the future. We will also appreciate to receive some insight on your project and the scenario you are using our RadControls suite. Did you stumble upon any problems during the implementation process? Do you find the controls difficult or simple in use?

    Maybe you've purchased our products under a different account? If so, please share it with us so we can update our records and provide you with adequate services.

    Sincerely yours,
    Paul
    the Telerik team

    Instantly find answers to your questions at the new Telerik Support Center

    Reply

  • Seth Intermediate avatar

    Posted on Mar 21, 2008 (permalink)

    Yes,

    I have been made aware of that.  Please see Ticket #126258.

    Seth

    Reply

  • Telerik Admin admin's avatar

    Posted on Mar 24, 2008 (permalink)

    Hello Seth,

    The FindControl method provides you with a reference to any control inside any of the templates used in the RadPanelBar or any of its PanelItems. You must make sure that you properly typecast the returned value as FindControl returns a reference to a Control class.

    After you get the reference you may modify any properties of the referenced control. For details on the matter, please take a look at the following example - Accessing Nested Controls.

    Please find below a sample code snippet that shows the needed approach.

     <form id="form2" runat="server">  
     
        <script type="text/javascript">  
        function getText()  
        {  
            var myTxtBox = document.getElementById("<%= RadPanelbar1.FindItemByValue("TemplateHolder").FindControl("TextBox1").ClientID %>");  
            alert(myTxtBox.value);  
        }  
        </script> 
     
        <radp:RadPanelbar ID="RadPanelbar1" runat="server">  
            <Items> 
                <radp:RadPanelItem runat="server" Text="Root RadPanelItem 1" Expanded="True">  
                    <Items> 
                        <radp:RadPanelItem runat="server" Value="TemplateHolder">  
                            <ItemTemplate> 
                                <asp:TextBox ID="TextBox1" runat="server">Test Message</asp:TextBox> 
                            </ItemTemplate> 
                        </radp:RadPanelItem> 
                    </Items> 
                </radp:RadPanelItem> 
            </Items> 
        </radp:RadPanelbar> 
        <input id="Button1" type="button" value="button" onclick="getText()" /> 
    </form> 


    All the best,
    Paul
    the Telerik team

    Instantly find answers to your questions at the new Telerik Support Center

    Reply

  • Kel Way avatar

    Posted on Feb 23, 2009 (permalink)

    I tried this,. and it works fine if textbox:
    var myTxtBox = document.getElementById("<%= RadPanelbar1.FindItemByValue("TemplateHolder").FindControl("TextBox1").ClientID %>");  
            alert(myTxtBox.value);  


    What if its a radcombobox that you are getting reference to?  When I do 

     

    var combo = document.getElementById("<%= RadPanelbar1.FindItemByValue("TemplateHolder").FindControl("ComboBox1").ClientID %>");  

     

     

    var items = combo.Items;

    I get error saying 'combo' is undefined...  Can I cast in js to RadCombobox?  I need to do this on client side. I need var combo to be object type of radcombobox, so I can manipulate it.

    THanks.

     

    Reply

Back to Top

Skip Navigation LinksHome / Community / Forums / ASP.NET > Panelbar > Get control contained in RadPanelBar RadPanelItem via javascript/client side

Powered by Sitefinity ASP.NET CMS

Contact Us | Site Feedback | Terms of Use | Privacy Policy
Copyright © 2002-2010 Telerik. All rights reserved.