Faulty documentation for RadPanelBar?

9 posts, 0 answers
  1. Patrik Johansson
    Patrik Johansson avatar
    270 posts
    Member since:
    May 2010

    Posted 28 Mar 2012 Link to this post

    If you look at the documentation for RadPanelBar, you will find:

    All server controls located in the templates are directly accessible by their IDs on Page-level. Instead of using the common syntax
            RadPanelBar1.Items[0].Header.FindControl("RadMenu1") //inside a HeaderTemplate
            RadPanelBar1.Items[0].FindControl("RadMultiPage1") //inside a ContentTemplate
        
    you can use RadMenu1 or RadMultiPage1 to reference the control located inside the respective template of the first root Item of a PanelBar.
     

    However, trying to actually use this functionality, it seems like controls within a RadPanelBar are not accessible without using the FindControl(). In a RadMultiPage though, it seems possible. Other post by Telerik personel here in the forum seem to confirm this. Or am I missing something here?

    http://demos.telerik.com/aspnet-ajax/panelbar/examples/functionality/templates/defaultcs.aspx
  2. Patrik Johansson
    Patrik Johansson avatar
    270 posts
    Member since:
    May 2010

    Posted 28 Mar 2012 Link to this post

    Actually, this seems to be semi-true. We can access controls in a RadPanelBar from code behind, but it seems other designers, like ObjectDataSource, can't find the controls that are in a RadPanelBar. That is, you can not choose to bind a parameter to a control residing within a RadPanelBar. Why is this and is there as solution (other than setting it in code behind)?

    And if the controls are accessible directly, why are there several posts here where support personnel from Telerik tell people to use the FindControl(), when it seems to work by naming them directly?  

    Perhaps I could rephrase, when will it work to access controls directly and when won't it? :)
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Kate
    Admin
    Kate avatar
    1898 posts

    Posted 02 Apr 2012 Link to this post

    Hi Patrik,

    Using header and content templates of the RadPanelItems you can directly access the needed control meaning that simply typing the  id of the control directly in the Page_Load event  is identical to typing the below lines of code (you can also refer to the attached image):
    var menu = panelbar1.Items[0].Header.FindControl("menu1");
    var menuu = panelbar1.Items[1].FindControl("menu3");

    However, you can not use the above mentioned approach when you have an ItemTemplate.

    Considering your other question with databinding can you please elaborate a bit more since I am not quite sure that I completely understand your question?

    Kind regards,
    Kate
    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.
  5. Patrik Johansson
    Patrik Johansson avatar
    270 posts
    Member since:
    May 2010

    Posted 02 Apr 2012 Link to this post

    If you try to reference the controls from code behind it will work, but if you try to use them in designers in design view it won't work. Like if you add an ObjectDataSource to the page, and then try to select any of the controls within the RadPanelBar to provide values for one of the parameters, it won't show up in the list of available controls. Please let me know if this explanation makes sense :)
  6. Kate
    Admin
    Kate avatar
    1898 posts

    Posted 03 Apr 2012 Link to this post

    Hi Patrik,

    Yes, it does make sense but currently you can bind a control that is in a template by using code behind as exemplified in the following help article -  Adding Templates at run-time.

    All the best,
    Kate
    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.
  7. Saikat
    Saikat avatar
    1 posts
    Member since:
    Oct 2011

    Posted 21 Apr 2012 Link to this post

    Hi Kate,
    "Using header and content templates of the RadPanelItems you can directly access the needed control meaning that simply typing the id of the control directly in the Page_Load event .."
    Is this statement valid for nested repeater controls also?If not, whats the way to find a nested repeater control?

    THanks,
    Saikat
  8. Kate
    Admin
    Kate avatar
    1898 posts

    Posted 25 Apr 2012 Link to this post

    Hi Saikat,

    The approach that I described is valid for any control that you place in the header and/or content templates of the RadPanelBar control. However, if your question is related to the asp Repeater control I would suggest that you take a look at the following post where it is explained how you can find a control placed in a template of a Repeater - How to find controls in a repeater header or footer 

    All the best,
    Kate
    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.
  9. Patrik Johansson
    Patrik Johansson avatar
    270 posts
    Member since:
    May 2010

    Posted 25 Apr 2012 Link to this post

    Please note that this thread is about faulty documentation, which claims that you can access controls in "templates" just by using their IDs, but reality is that this only works in a few cases, but not in others. Should perhaps be highlighted.
  10. Kate
    Admin
    Kate avatar
    1898 posts

    Posted 26 Apr 2012 Link to this post

    Hello Patrik,

    The demo that you refer to demonstrates that controls placed in Header and /or Content templates of RadPanelBar are accessible directly from the page. For instance if you place a RadAjaxManager control on the page containing a RadPanelBar with templates, you would be able to find any control placed in the template. Did you try to reproduce the same issue with any other asp.net control? Can you also record a video that demonstrates the issue that you describe in designers in design views since I am not completely sure that I understand it?

    Greetings,
    Kate
    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.
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017