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

Question about best practice by 'RadPanelBar' control items appending.

3 Answers 59 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
SCT
Top achievements
Rank 1
SCT asked on 14 Sep 2011, 08:44 AM
Dear Telerik Team,

we would like to ask you for the difference by these two known approaches: (in order to append nested items)

Code Snippet #1:

<telerik:RadPanelBar runat="server" ID="RadPanelBar1" Width="100%">

    <Items>

        <telerik:RadPanelItem Expanded="True" Text="Example1" Selected="true">

            <Items>

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

                    <ItemTemplate>


Code Snippet #2:

<telerik:RadPanelBar runat="server" ID="RadPanelBar1" Width="100%" Height="100%">

<Items>

                  <telerik:RadPanelItem Text=" Example2">

                  <ContentTemplate>


Both of mentioned constructions work fine, and their final visual results seem be the same and desired, as well. We've determined that construction shown on the first code snippet is mostly used on your official telerik examples websites. However, we found the second approach in addition.

Can you provide us some advice or evaluation about advantages/disadvantages of mentioned approaches (which of them is better and why),   please?
Thank you in advance.

Regards,
SCT

3 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 14 Sep 2011, 12:57 PM
Hello,

If the RadPanelBar has items with content templates then it can access the controls embedded in the content templates directly by ID, regardless of the level of the template itself.

If your RadPanelBar has items with item templates that have embedded controls, you may want to access the properties of those embedded controls. To get a reference to the embedded control, locate the RadPanelBarItem that has the item template, and use its FindControl method.

Please take a look into the following help article which explains the same.
Accessing Controls Inside Templates.

Thanks,
Princy.
0
Kate
Telerik team
answered on 14 Sep 2011, 03:22 PM
Hi SCT,

If you use item template then you need to have a child item for your root items. While with content template this is not necessary. Furthermore with the ContentTemplate of panelbar  (available since Q2 2010 release), you can reference the controls in it directly with their ID (no need to use FindControl method) as Shinu explained. With both ContentTemplate and ItemTemplate you have the ability to create global templates. However, in case you have a global template for all items, by using a ContentTemplate you can apply a specific appearance for a specific RadPanelItem that will take precedence over the global template.

Also with the ContentTemplate you have a HeaderTemplate that you can use for further customization of a PanelBar Item. Depending on your requirements you could use either or both templates.

You can read more about these templates in following help topic and demo below:
http://www.telerik.com/help/aspnet-ajax/panelbar-templates-overview.html
http://demos.telerik.com/aspnet-ajax/panelbar/examples/functionality/templates/defaultvb.aspx

Greetings,
Kate
the Telerik team
Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal
0
SCT
Top achievements
Rank 1
answered on 16 Sep 2011, 12:04 PM
Hi Princy, Hi Kate,

thank you very much for your response.

Kind regards,
SCT
Tags
General Discussions
Asked by
SCT
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Kate
Telerik team
SCT
Top achievements
Rank 1
Share this question
or