Finding controls in a tab template

4 posts, 0 answers
  1. Ian Wells
    Ian Wells avatar
    25 posts
    Member since:
    Jul 2009

    Posted 19 Mar 2010 Link to this post

    Hi All,

    I have a tab template in my tabstrip that contains a label and an image. I need to populate the text of the label at runtime as it should say how results are returned. I just cannoy figure out how to get the embedded control. I have tried the usual 'FindControl' method to no avail. This code is in the Telerik help docs for templates, but it is for ItemTemplate not TabTemplate:

    Control ButtonWithTemplate = RadToolBar1.FindItemByValue("ButtonWithTemplate"); 

    Can anyone please help me on this?

    Thanks
    Ian


  2. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 19 Mar 2010 Link to this post

    Hello Ian Wells,

    I tried following code in order to access the Label placed in 'TabTemplate'.

    CS:

     
        RadTab ButtonWithTemplate = (RadTab)RadTabStrip1.FindTabByValue("ButtonWithTemplate");  
        (ButtonWithTemplate.FindControl("Label2"as Label).Text = "hai"

    ASPX:

     
       . . .  
        <telerik:RadTab runat="server" Text="person" Value="ButtonWithTemplate">  
            <TabTemplate>  
                <asp:Label ID="Label2" runat="server" Text="Label"></asp:Label>  
            </TabTemplate>  
            <Tabs>  
                <telerik:RadTab runat="server" Text="Child RadTab 1">  
                </telerik:RadTab>  
            </Tabs>  
        </telerik:RadTab>  
       . . . 

    But from your code, I can see that you used "RadToolBar1.FindItemByValue" instead of RadTabStrip controlID. Please check that you tried exact control only.

    Feel free to share the comments,

    Shinu.

  3. Ian Wells
    Ian Wells avatar
    25 posts
    Member since:
    Jul 2009

    Posted 19 Mar 2010 Link to this post

    Hi Shinu,

    Thanks for your reply. Sorry I think I have added to some confusion here. The code I pasted is not what I am using, I just took that example from the telerik support documentation.

    I will try the example that you have suggested.

    Regards,
    Ian
  4. Ian Wells
    Ian Wells avatar
    25 posts
    Member since:
    Jul 2009

    Posted 19 Mar 2010 Link to this post

    Thanks Shinu, following this solution worked!

    Ian
Back to Top