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

How to access controls inside a TabTemplate

3 Answers 70 Views
TabStrip
This is a migrated thread and some comments may be shown as answers.
smith spd
Top achievements
Rank 1
smith spd asked on 12 Jul 2010, 10:05 PM
Hello,

Can somebody tell me how do I access an image (html control) inside the TabTemplate from the Server Side?

Thanks

3 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 13 Jul 2010, 05:58 AM
Hello Smith,


You need to get reference to corresponding TabStrip and use the FindControl() method to access the control placed inside it.

C#:
RadTab tab = (RadTab)RadTabStrip1.FindTabByText("TabText"); // Get the tab
HtmlImage image1 = (HtmlImage)tab.FindControl("Image1"); // Image1 is Id of HTML image in TabTemplate
image1.Visible = false;


And the relevant aspx is:
<telerik:RadTab runat="server" Selected="True" Text="test">
    <TabTemplate>
        <img alt="click me to edit" runat="server" id="Image1" src="../Images/Edit.gif" />         
    </TabTemplate>
</telerik:RadTab>
[Addrunat="server" to image control access the from code behind]


-Shinu.
0
smith spd
Top achievements
Rank 1
answered on 15 Jul 2010, 08:14 PM
Thank you shinu.
I m closing tabs using javascript in the above ref.
But, if I want to close the dynamically created tabs. This javascript doesn't work.
Can you let me know how to achieve this?
I have small snippet to close the tabs dynamically but I have that not working properly.
Protected Sub ImgBtn_Click(ByVal sender As Object, ByVal e As EventArgs)
        Dim currentTab As RadTab = tabContainer.InnermostSelectedTab
  
        If currentTab IsNot Nothing Then
            Dim owner As IRadTabContainer = currentTab.Owner
            tabMultiPage.PageViews.RemoveAt(tabMultiPage.SelectedIndex)
            owner.Tabs.Remove(currentTab)
            If owner.Tabs.Count > 0 Then
                owner.SelectedIndex = 0
            End If
        End If
  
    End Sub

Please help.
Would be of great help if you can resolve one of my issues here
0
Yana
Telerik team
answered on 21 Jul 2010, 09:53 AM
Hi smith,

I cannot reproduce this issue with the provided code. Please send us sample code which will help us observe the problem.

Best wishes,
Yana
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Tags
TabStrip
Asked by
smith spd
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
smith spd
Top achievements
Rank 1
Yana
Telerik team
Share this question
or