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

access textbox in button click

1 Answer 73 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Tina
Top achievements
Rank 1
Tina asked on 06 Mar 2012, 08:08 AM
How can I access the textbox in button click event?
  <NestedViewTemplate>
      <asp:Button ID="Button1" runat="server" onclick="Button1_Click" />
            <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
</NestedViewTemplate>

1 Answer, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 06 Mar 2012, 08:17 AM
Hello Tina,

Try the following code.
C#:
protected void Button1_Click(object sender, EventArgs e)
{
 Button button1 = (Button)sender;
 GridNestedViewItem item = (GridNestedViewItem)button1 .NamingContainer;
 TextBox txtbox = (TextBox)item.FindControl("TextBox1");           
}

-Shinu.
Tags
General Discussions
Asked by
Tina
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Share this question
or