Asp.net 使用asp控件获取文本属性
我使用以下代码创建了控件:Asp.net 使用asp控件获取文本属性,asp.net,text,controls,properties,Asp.net,Text,Controls,Properties,我使用以下代码创建了控件: ...Page_Load(...) { ... TextBox tBox = new TextBox(); tBox.ID ="SpecificID"; somePanel.Controls.Add(tBox); ... } 如何使用此控件获取文本属性(如specifiid.Text) 我假设您提到的“somePanel”是您在页面中使用的asp.net面板控件 我假设您提到的“somePanel”是您在页面中使用的asp.net面板控件 TextBox textB
...Page_Load(...)
{
...
TextBox tBox = new TextBox();
tBox.ID ="SpecificID";
somePanel.Controls.Add(tBox);
...
}
如何使用此控件获取文本属性(如specifiid.Text
)
我假设您提到的“somePanel”是您在页面中使用的asp.net面板控件
我假设您提到的“somePanel”是您在页面中使用的asp.net面板控件
TextBox textBox = Form.FindControl("yourid") as TextBox
string text = textBox.Text
TextBox tBox = new TextBox();
tBox.ID = "1";
tBox.Text = "hi";
form1.Controls.Add(tBox);
string Text= tBox.Text;
TextBox textBox = somePanel.FindControl("SpecificID") as TextBox;
string text = textBox.Text;