How do i access controls serverside??

3 posts, 1 answers
  1. lkj lkj
    lkj lkj avatar
    12 posts
    Member since:
    Jan 2010

    Posted 04 Feb 2010 Link to this post

    How do i access controls serverside?

    If i have
    <telerik:radPanelItem text="test">
        <Items>
             <Telerik:radPanelItem>
                       <ItemTemplate>
                                <asp:button Id="Button1" runat="server" text="Button" />
                                <asp:textbox id="Textbox1" runat="server"></asp:TextBox>


    If i fire the button in a button_click how do i get the value of textbox1 on the server??
  2. Answer
    Schlurk
    Schlurk avatar
    812 posts
    Member since:
    May 2009

    Posted 04 Feb 2010 Link to this post

    You could do something like this:

    ASPX:
        <asp:Button ID="myButton" runat="server" Text="Find" OnClick="myButton_Click" /> 
        <telerik:RadPanelBar ID="RadPanelBar1" runat="server"
            <Items> 
                <telerik:RadPanelItem Text="Test"
                    <Items> 
                        <telerik:RadPanelItem Value="Second"
                            <ItemTemplate> 
                                <asp:Button ID="Button1" runat="server" Text="Button" /> 
                                <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox> 
                            </ItemTemplate> 
                        </telerik:RadPanelItem> 
                    </Items> 
                </telerik:RadPanelItem> 
            </Items> 
        </telerik:RadPanelBar> 

    C#:
        protected void myButton_Click(object sender, EventArgs e) 
        { 
            RadPanelItem myItem = new RadPanelItem(); 
            myItem = RadPanelBar1.FindItemByValue("Second"); 
            TextBox myTextBox = (TextBox)myItem.FindControl("TextBox1"); 
            Response.Write("Found: " + myTextBox.Text + "<br />"); 
        } 

  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. lkj lkj
    lkj lkj avatar
    12 posts
    Member since:
    Jan 2010

    Posted 05 Feb 2010 Link to this post

    Excellent
Back to Top