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

Finding controls in a tab template

3 Answers 141 Views
TabStrip
This is a migrated thread and some comments may be shown as answers.
Ian Wells
Top achievements
Rank 1
Ian Wells asked on 19 Mar 2010, 09:20 AM
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


3 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 19 Mar 2010, 11:38 AM

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.

0
Ian Wells
Top achievements
Rank 1
answered on 19 Mar 2010, 11:55 AM
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
0
Ian Wells
Top achievements
Rank 1
answered on 19 Mar 2010, 12:40 PM
Thanks Shinu, following this solution worked!

Ian
Tags
TabStrip
Asked by
Ian Wells
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Ian Wells
Top achievements
Rank 1
Share this question
or