Get Text property with asp control
I created control using code:
...Page_Load(...)
{
...
TextBox tBox = new TextBox();
tBox.ID ="SpecificID";
somePanel.Controls.Add(tBox);
...
}
How to get Text property开发者_运维百科 with this control (like SpecificID.Text
)???
TextBox textBox = Form.FindControl("yourid") as TextBox
string text = textBox.Text
TextBox textBox = somePanel.FindControl("SpecificID") as TextBox;
string text = textBox.Text;
i assume "somePanel" you have referred is a asp.net panel control you are using in the page.
TextBox tBox = new TextBox();
tBox.ID = "1";
tBox.Text = "hi";
form1.Controls.Add(tBox);
string Text= tBox.Text;
精彩评论