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

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

问题描述

我的asp.net页面上有一堆文本框,在TextChanged事件上,我想运行一个存储的proc以根据用户输入返回 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;

如何获取 .Text 的值

how can I get the .Text value of objTextBox?

推荐答案

使用它代替:

string objTextBox = t.Text;

对象 t TextBox 。调用 objTextBox 的对象已分配 TextBox ID 属性c>。

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

所以更好的代码是:

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

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

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