E
Edward
hi, everyone,
my Page_Load fill tblProducts with some TextBox.
<form runat="server">
<asp:Table id="tblProducts" runat="server"></asp:Table>
<hr>
<asp:Button id="Button1" onclick="Button1_Click" runat="server"
Text="Button"></asp:Button>
<hr>
<hr>
<asp:TextBox id="test" runat="server"/>
</form>
the method is :
TextBox getTextBox() {
TextBox txt = new TextBox();
txt.ID = "txtNum" + Convert.ToString(TextBoxCnt);
TextBoxCnt ++;
return txt;
}
when I use :
TextBox txt = (TextBox)Page.FindControl("txtNum" + Convert.ToString(i));
in the script of Button_Click, I cannot find the control. but in
Page_Load , I can get it.
And in Button_Click, TextBox "test" can be find.
How can I find the program-added controls in Button_Click?
thanks.
my Page_Load fill tblProducts with some TextBox.
<form runat="server">
<asp:Table id="tblProducts" runat="server"></asp:Table>
<hr>
<asp:Button id="Button1" onclick="Button1_Click" runat="server"
Text="Button"></asp:Button>
<hr>
<hr>
<asp:TextBox id="test" runat="server"/>
</form>
the method is :
TextBox getTextBox() {
TextBox txt = new TextBox();
txt.ID = "txtNum" + Convert.ToString(TextBoxCnt);
TextBoxCnt ++;
return txt;
}
when I use :
TextBox txt = (TextBox)Page.FindControl("txtNum" + Convert.ToString(i));
in the script of Button_Click, I cannot find the control. but in
Page_Load , I can get it.
And in Button_Click, TextBox "test" can be find.
How can I find the program-added controls in Button_Click?
thanks.