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

Trouble accessing nested controls with javascript

4 Answers 147 Views
PanelBar
This is a migrated thread and some comments may be shown as answers.
William
Top achievements
Rank 1
William asked on 20 Oct 2008, 08:58 AM
Hi, I'm uuterly useless with Javascript but need to access a nested control in a RadPanelBar with it. I have used the following but still it returns a null value.

var myPlaceHolderIR = document.getElementById("<%= RadPanelBar1.FindItemByValue("Step3").FindControl("PlaceHolder_IPRestriction").ClientID %>");

Any help greatly appreciated.



4 Answers, 1 is accepted

Sort by
0
Veselin Vasilev
Telerik team
answered on 20 Oct 2008, 12:16 PM
Hi William,

Please check this help topic: Templates > Accessing Controls Inside Templates

Kind regards,
Veselin Vasilev
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
William
Top achievements
Rank 1
answered on 20 Oct 2008, 12:42 PM
0
bdk0172
Top achievements
Rank 1
answered on 02 Feb 2009, 07:33 PM
I have a few controls all within one panelbaritem.  When attempting to access the controls using the section you reference, I am successful in accessing two radDatePicker controls, but not an asp:RadioButtonList.

 

var panelbar = $find('<%=RadPanelBar1.ClientID %>');

 

 

var item = panelbar.findItemByText('Ticket Dispatching');

 

 

 

 

var rdoList = item.findControl('rbDate');

 

 

var dateFrom = item.findControl('RadDateFrom');

 

 

var dateThrough = item.findControl('RadDateThrough');

The line of code, var rdoList = item.findControl('rbDate');, returns null.  Does something different need to be done in order to access Microsoft asp controls?

 

0
Paul
Telerik team
answered on 03 Feb 2009, 02:46 PM
Hi bdk0172,

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

<form id="form1" runat="server"
    <telerik:RadScriptManager ID="RadScriptManager1" runat="server"
    </telerik:RadScriptManager> 
 
    <script type="text/javascript"
    function getRBList() 
    { 
       var rdoList = $get('<%= ((RadioButtonList)RadPanelBar1.FindItemByValue("templateHolder").FindControl("RadioButtonList1")).ClientID %>'); 
        alert(rdoList); 
    } 
    </script> 
 
    <telerik:RadPanelBar ID="RadPanelBar1" runat="server"
        <CollapseAnimation Type="None" Duration="100"></CollapseAnimation> 
        <Items> 
            <telerik:RadPanelItem runat="server" Text="Root RadPanelItem1"
                <Items> 
                    <telerik:RadPanelItem runat="server" Value="templateHolder"
                        <ItemTemplate> 
                            <asp:RadioButtonList ID="RadioButtonList1" runat="server"
                                <asp:ListItem>test1</asp:ListItem> 
                                <asp:ListItem>test2</asp:ListItem> 
                                <asp:ListItem>test3</asp:ListItem> 
                            </asp:RadioButtonList> 
                        </ItemTemplate> 
                    </telerik:RadPanelItem> 
                </Items> 
            </telerik:RadPanelItem> 
        </Items> 
        <ExpandAnimation Type="None" Duration="100"></ExpandAnimation> 
    </telerik:RadPanelBar> 
    <input id="Button1" type="button" value="button" onclick="getRBList()" /> 
</form> 


Greetings,
Paul
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
Tags
PanelBar
Asked by
William
Top achievements
Rank 1
Answers by
Veselin Vasilev
Telerik team
William
Top achievements
Rank 1
bdk0172
Top achievements
Rank 1
Paul
Telerik team
Share this question
or