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

Cannot find controls inside ItemTemplate of RadPanelBar

2 Answers 339 Views
PanelBar
This is a migrated thread and some comments may be shown as answers.
Covertix
Top achievements
Rank 1
Covertix asked on 03 May 2012, 12:45 PM
Hi

I have a RadPanelBar, and I can't find controls inside the ItemTemplate.
I read:Help documentation for accessing item: Accessing Items
Help documentation for accessing control inside: Accessing Controls Inside Templates
But it doesn't work for me.

here is my code:

 

<telerik:RadPanelBar ID="rpbAddFilters" runat="server">

    <Items>

        <telerik:RadPanelItem Text="RadPanelItem" runat="server">

            <Items>

                <telerik:RadPanelItem Value="test" runat="server">

                    <ItemTemplate>

                        <telerik:RadCodeBlock ID="RadCodeBlock2" runat="server">

 

                                        <asp:Panel ID="pnlValues" runat="server">

 

                                `       </asp:Panel>


                        </telerik:RadCodeBlock>

                  </ItemTemplate> 
                </telerik:RadPanelItem >
            </Items>
         </telerik:RadPanelItem >
    </Items>
</RadPanelBar>

 

 





function find()
{

    var panelbar = $find("<%= rpbAddFilters.ClientID %>");

 

  

    var item = panelbar.findItemByValue("test");

    var pnlValues = item.findControl("pnlValues");

}



I get null value for pnlValues.


Thanks.

2 Answers, 1 is accepted

Sort by
0
Vuyiswa
Top achievements
Rank 2
answered on 04 May 2012, 11:37 AM
Ok i dont have an Example for javascript but i cant show you how you can do it on the server side. So in my case i have a "ReportViewer" inside the item so the following code finds the REportviewer inside an itemtemplate



Dim RadPanelBar1 As RadPanelBar = CType(sender, RadPanelBar)
                Dim InnerPanel As RadPanelItem = CType(RadPanelBar1.FindItemByValue("Impairment"), RadPanelItem)
                Dim rptreportviewer As Microsoft.Reporting.WebForms.ReportViewer = CType(InnerPanel.FindControl("rptImpairment"), Microsoft.Reporting.WebForms.ReportViewer)


             So look at the Value option, i use that to find the control inside the ItemTemplate 

  <telerik:RadPanelBar ID="RadPanelBar1" runat="server" ExpandMode="FullExpandedItem"
      Height="500px" Skin="Hay" Width="862px">
      <Items>
<telerik:RadPanelItem    Text="Impairment">
              <Items>
                  <telerik:RadPanelItem Value="Impairment">
                      <ItemTemplate>
                          <rsweb:ReportViewer Width="100%" Height="500px" ID="rptImpairment" runat="server">
                          </rsweb:ReportViewer>
                      </ItemTemplate>
                  </telerik:RadPanelItem>
              </Items>
          </telerik:RadPanelItem>
      </Items>
  </telerik:RadPanelBar>
0
Peter
Telerik team
answered on 07 May 2012, 08:26 AM
Hi Tzach,

To access nested controls client-side, you need to be sure that the control in question has a client  side object. Most Telerik RadControls for ASP.NET AJAX have a client object, but the standard ASP Panel does not have a client object hence the error that you have experienced.

All the best,
Peter
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.
Tags
PanelBar
Asked by
Covertix
Top achievements
Rank 1
Answers by
Vuyiswa
Top achievements
Rank 2
Peter
Telerik team
Share this question
or