System.Web.UI.WebControl.Textbox 不包含 Text 的定义
本文关键字:包含 Text 定义 Textbox Web UI WebControl System | 更新日期: 2023-09-27 18:36:44
我需要从Web表单上的文本框中获取文本值。在文档中,它提到System.Web.UI.WebControl.Textbox有一个属性Text,但是当我尝试使用它时出现错误。
string FieldName= "";
string FieldValue="";
if (inputValues[i] is System.Web.UI.WebControls.TextBox)
{
FieldName = inputValues[i].ClientID;
FieldValue = inputValues[i].Text; // error
}
显示的错误为 System.Web.UI.WebControl.Textbox does not contain the definition of Text
。如何从文本框控件中获取文本值?
尝试将inputValues[i]
转换为System.Web.UI.WebControl.Textbox
。然后访问Text
属性:
FieldValue = ((System.Web.UI.WebControl.Textbox)(inputValues[i])).Text;