use*_*521 12 c# asp.net textbox .net-3.5
我的asp.net页面上有一堆文本框,而在TextChanged事件中,我想运行一个存储过程,根据用户输入返回一个Name.如果我有一个代码块,如:
TextBox t = (TextBox)sender;
string objTextBox = t.ID;
Run Code Online (Sandbox Code Playgroud)
我怎样才能获得.TextobjTextBox 的值?
Kie*_*one 30
请改用:
string objTextBox = t.Text;
对象t是TextBox.您调用的对象objTextBox被赋予了该ID属性TextBox.
所以更好的代码是:
TextBox objTextBox = (TextBox)sender;
string theText = objTextBox.Text;
Run Code Online (Sandbox Code Playgroud)
if(sender is TextBox) {
var text = (sender as TextBox).Text;
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
186150 次 |
| 最近记录: |