2011-07-05 7 views
0

I créé en utilisant le code de contrôle:Get propriété Text avec contrôle asp

...Page_Load(...) 
{ 
... 
TextBox tBox = new TextBox(); 
tBox.ID ="SpecificID"; 
somePanel.Controls.Add(tBox); 
... 
} 

Comment obtenir la propriété de texte avec ce contrôle (comme SpecificID.Text) ???

Répondre

1
TextBox textBox = somePanel.FindControl("SpecificID") as TextBox; 
string text = textBox.Text; 

je suppose "somePanel" vous avez fait allusion est un contrôle du panneau de asp.net que vous utilisez dans la page.

2
TextBox textBox = Form.FindControl("yourid") as TextBox 
string text = textBox.Text 
1
 TextBox tBox = new TextBox(); 
     tBox.ID = "1"; 
     tBox.Text = "hi"; 
     form1.Controls.Add(tBox); 

     string Text= tBox.Text; 
Questions connexes