Accessing control values

2 posts, 0 answers
  1. Paula
    Paula avatar
    13 posts
    Member since:
    Jun 2012

    Posted 06 Jul 2010 Link to this post

    I want to have a tabstrip with a text box on it but I cant access the value of the textbox in code behind.  What am I missing? This should be simple but I cannot find the answer anywhere.

     

    <telerik:RadTabStrip ID="RadTabStrip1" runat="server" SelectedIndex="0">

     

     

    <Tabs>

     

     

    <telerik:RadTab runat="server" Selected="True" Text="test">

     

     

    <TabTemplate>

     

     

    <asp:TextBox ID="TextBox1" runat="server" ontextchanged="TextBox1_TextChanged"></asp:TextBox>

     

     

    <asp:LinkButton ID="LinkButton1" runat="server" onclick="LinkButton1_Click">LinkButton</asp:LinkButton>

     

     

    </TabTemplate>

     

     

    </telerik:RadTab>

     

     

    </Tabs>

     

     

    </telerik:RadTabStrip>

     



     

    Protected Sub LinkButton1_Click(ByVal sender As Object, ByVal e As System.EventArgs)

     

     

    Dim rad As TextBox = RadTabStrip1.FindControl("TextBox1")

     

    Response.Write(rad.Text)

     

    End Sub

     



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

    Posted 07 Jul 2010 Link to this post

    Hello Paula,

    You need to access corresponding RadTab and then use the FindControl() method to get reference to control placed in ItemTemplate.

    VB:
     
    Dim tab As RadTab = DirectCast(RadTabStrip1.FindTabByText("test"), RadTab) 
    Dim rad As TextBox = DirectCast(tab.FindControl("TextBox1"), TextBox) 
    Response.Write(rad.Text) 
     


    -Shinu.
Back to Top