从TextBox获取.Text值

我的asp.net页面上有一堆文本框,而在TextChanged事件中,我想运行一个存储过程,根据用户输入返回一个Name 。 如果我有一个代码块,如:

TextBox t = (TextBox)sender; string objTextBox = t.ID; 

我如何获得objTextBox的.Text值?

改为使用它:

string objTextBox = t.Text;

对象tTextBox 。 您调用objTextBox的对象被赋予TextBoxID属性。

所以更好的代码是:

 TextBox objTextBox = (TextBox)sender; string theText = objTextBox.Text; 
 if(sender is TextBox) { var text = (sender as TextBox).Text; } 

你尝试过使用t.Text吗?