从 TextBox 获取 .Text 值 [英] Getting the .Text value from a TextBox

查看:31
本文介绍了从 TextBox 获取 .Text 值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I have a bunch of textboxes on my asp.net page, and on TextChanged event, I want to run a stored proc to return a Name, based on user input. If I have a block of code like:

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

如何获取objTextBox的.Text值?

how can I get the .Text value of objTextBox?

推荐答案

改用这个:

string objTextBox = t.Text;

对象tTextBox.您调用 objTextBox 的对象被分配了 TextBoxID 属性.

The object t is the TextBox. The object you call objTextBox is assigned the ID property of the TextBox.

所以更好的代码应该是:

So better code would be:

TextBox objTextBox = (TextBox)sender;
string theText = objTextBox.Text;

这篇关于从 TextBox 获取 .Text 值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆